Displaying 1 result from an estimated 1 matches for "as_floats".
Did you mean:
apfloats
2016 Sep 29
4
a proposed script to help with test-suite programs that output _lots_ of FP numbers
...m_floats.py
----------------------------------------
#!/usr/bin/python
import math, sys
try_for_more = True
count = 0
total = 0.0
while try_for_more:
line = sys.stdin.readline()
if line:
split_line = line.split() # handles ASCII horizontal tabs as well as ASCII horizontal spaces
as_floats = [float(x) for x in split_line]
for the_float in as_floats:
if not ( math.isinf(the_float) or math.isnan(the_float) ):
count = count + 1
total = total + the_float
else:
try_for_more = False # cleaner than "break", I suppose
print (count)
print (tota...