Saturday 22 September 2018

How do I print double in Python with exact precision?

I need to print double with precision equal exactly to 6, I found function round:



print(str(round(result, 6))


But in case result itself has less precision, the print function skips zeros at the end.



Gor example, the output of such code,



print(str(round(4.0, 6)))



is



4.0


But what I need is



4.000000



How can I reach this?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...