0

Every time I do something like x186.733 it gives something like 396.328679362906736. How can I avoid? I tried 1.3*2.68 and it gives 2 extra 0s at the end, its very annoying.

Jealousy
  • 57
  • 3
  • 4
    Answered here: https://stackoverflow.com/questions/1458633/how-to-deal-with-floating-point-number-precision-in-javascript – Steve Aug 13 '21 at 03:02
  • `1.3*2.68 and it gives 2 extra 0s at the end` ... no it doesn't ... it gives `0000000000004` at the end - you must be doing something very different – Bravo Aug 13 '21 at 03:18

1 Answers1

1

Use Math.round() to get the nearest one.

Phenomenon
  • 104
  • 7