Python - number of significant digits in split results

Newbie here. I have the following code:

myADC = 128
maxVoltage = 5.0
maxADC = 255.0
VoltsPerADC = maxVoltage/maxADC
myVolts = myADC * VoltsPerADC
print "myADC = {0: >3}".format(myADC)
print "VoltsPerADC =  {0: >7}".format(VoltsPerADC)
print VoltsPerADC
print "myVolts = {0: >7}".format(myVolts)
print myVolts

Outputs the following:

myADC = 128
VoltsPerADC =  0.0196078
0.0196078431373
myVolts =  2.5098
2.50980392157

I was looking for an explanation of how the number of significant digits is determined by default, but I had trouble finding an explanation that makes sense to me. This link link text assumes that by default the "print" operator prints numbers up to 10 significant digits, but this does not seem to have a place in my results.

How is the number of significant digits / accuracy determined?

Can someone shed some light on this for me.

Thanks in advance for your time and patience.

+3
source share
2 answers

, python.org, . print, , float ( Thomas ), double - , .

0

Source: https://habr.com/ru/post/1739449/


All Articles