-4

I couldn't think of a better name. Please feel free to edit. On Python, I tried rounding the number 6.2 to 15 decimal places after seeing this thread and got:

   round(6.2,15)
   => 6.2000000000000002

Great! Now I try the same thing for 1.2 and:

   round(1.2,15)
   => 1.2

Huh? That's my only reaction.

Community
  • 1
  • 1
Ahaan S. Rungta
  • 2,323
  • 2
  • 12
  • 15

1 Answers1

1

This is the string format:

"{:.15f}".format(1.2)

Maybe next article can help:

Floating Point Arithmetic: Issues and Limitations http://docs.python.org/3.3/tutorial/floatingpoint.html

Cosmin
  • 64
  • 1
  • 8