0

There is a point in my program where I compare a number with zero and if it is zero I execute a series of commands. The number calculated should be zero for some conditions but it just comes out to be a really small number (**(-17)) instead of exactly zero. So, I am planning to use format to rectify that by making very small numbers zero. I test ran this below and this simple code did not work.

I avoided using round because that might hinder the precision I want in my my code.

Is there a way implement format so that it works how I want it to?

Here:

a='{:.5f}'.format(0.00000056)
print(a)
if a==0.:
  print('success')

output:

0.00000
Lost
  • 203
  • 1
  • 10

0 Answers0