Why does float() cut off trailing zeros?
问题 The code successfully crops a large file of many numbers to several smaller text files with number, but it produces an interesting quirk. All numbers should be to four decimal points like 2.7400 but instead they print as 2.74. Here is a snippet from a file 0.96 0.53 0.70 0.53 0.88 0.97 Why does this happen? Is there a way to fix this or this just a quirk of float()? from itertools import islice def number_difference(iterable): return float(iterable[-1].strip('\n')) - float(iterable[0].strip('