0

I have 2 float number and I try to get the multiple. But in the console it does not get the correct one. I do not know maybe there is a leak ?

{"price"=>"0.049391", "size"=>"0.001"}

When I multiple them console shows;

************
0.049391
************
0.001
************
4.9390999999999995e-05
************

Then when I push this data to array and in front end when I console.log

I get;

0.000049390999999999995

Why it is not 0.0000493901 ?

Shalafister's
  • 761
  • 1
  • 7
  • 34

1 Answers1

1

4.9390999999999995e-05 and 0.000049390999999999995 are the same number. e-05 is nothing more than notation for "move the decimal place five spots to the left".

Derek Kraan
  • 129
  • 1
  • 4
  • The OP wants 0.000049391, not 0.000049390999999999995 – Stefan Dec 28 '17 at 12:00
  • Ah, right you are. Well in that case OP is SOL, because this is just a quirk of floating point precision, and the answer has been rightly marked as a duplicate. – Derek Kraan Dec 29 '17 at 10:00