ketting00 — 2014-03-11T10:42:15-04:00 — #1
I think I'm too stupid to solve this math equation myself.
0.05 * 0.05 = 0.0025
How do I make the result having greater value like 0.25, like they multiply integral number.
I want the numbers lesser than zero multiply with each another to having greater value not lesser.
mittineague — 2014-03-11T10:48:41-04:00 — #2
Sorry, I don't understand you.
.05 times .05 is .0025
So that result is correct. You want to purposely get an incorrect result?
ketting00 — 2014-03-11T11:06:33-04:00 — #3
Sorry, I must be very stupid at math.
I want something like: 0.05 + 0.05 + 0.05 + 0.05 +0.05
It must multiply with integral number. A kindergarten could do this.
mittineague — 2014-03-11T11:18:21-04:00 — #4
I don't know about that. When I was in kindergarten they didn't teach me decimals or fractions.
So what you want is
.05 times 5
5 5 25
-- x -- = --
100 1 100
.05 times .05
5 5 25
-- x -- = --
100 100 10000
ketting00 — 2014-03-11T11:25:34-04:00 — #5
Thanks, that's more likely.
I calculate two time stamps. The first one is actually 0.0012208 seconds and the second is 0.0743354146 seconds.
I want to multiply them. It's impossible to have lesser value.
felgall — 2014-03-11T14:28:13-04:00 — #6
No programming language can multiply decimal fractions accurately because they all work with binary fractions.
If you want an accurate answer you need to make them all integers first and only convert back to a fraction at the end.
mittineague — 2014-03-11T14:48:33-04:00 — #7
Doing something like
var result = ( (timestamp1 * 1000000000) * (timestamp2 * 1000000000) ) / 1000000000;
might give a more accurate result without losing precision, but I have to wonder why would timestamps ever need to be multiplied?
felgall — 2014-03-11T16:42:04-04:00 — #8
would give a wrong answer - you are multiplying by 1000000000000000000 but only dividing by 1000000000. The actual answer would be 1/1000000000 of what that calculation would produce.
The problem with converting to integers so as to not lose precision is in keeping track of what to divide by at the end.
mittineague — 2014-03-11T16:57:20-04:00 — #9
:d'oh: right you are, thanks for catching that. The point I was focusing on (and obviously not giving much thought to the rest ) was why would one want to multiply timestamps?
ketting00 — 2014-03-11T20:16:24-04:00 — #10
Thanks for help. I called it wrongly. It's speed not timestamps. Problem with all not native English speaker I guess.
ketting00 — 2014-03-11T20:52:37-04:00 — #11
Addition: by speed, more multiple factors mean delay.
mittineague — 2014-03-11T23:28:25-04:00 — #12
That makes more sense.
I would do something like
duration = end_timestamp - start_timestamp
for each thing you're timing. That would give you units of actual time to work with which you could convert to milli or micro seconds and should be a lot better to use IMHO