Help with Math and JavaScript

I think I’m too stupid to solve this math equation myself.
Given:


0.05 * 0.05 = 0.0025

How do I make the result having greater value like 0.25, like they multiply integral number.

Was this possible at all and how do you calculate in JavaScript.

I want the numbers lesser than zero multiply with each another to having greater value not lesser.

Thanks

Sorry, I don’t understand you.

.05 times .05 is .0025

So that result is correct. You want to purposely get an incorrect result?

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.

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

not
.05 times .05

5          5         25
--    x   --     =   --
100       100      10000

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.

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.

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?

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.

:d’oh: right you are, thanks for catching that. The point I was focusing on (and obviously not giving much thought to the rest :blush: ) was why would one want to multiply timestamps?

Thanks for help. I called it wrongly. It’s speed not timestamps. Problem with all not native English speaker I guess.

Addition: by speed, more multiple factors mean delay.

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