# L-25 MCS 507 Wed 19 Oct 2011 : flopsum.py

# We use FlopFloats to count the number
# of operations when summing n floats.

from flopfloats import *
from random import gauss

print 'counting flops in a sum' + \
      ' of n floating-point numbers'
n = input('Give n : ')
sum = FlopFloat()
for i in range(0,n):
   r = FlopFloat(gauss(0,1))
   sum = sum + r
print 'sum = ' + str(sum) + \
   ' #flops is %d' % sum.flops
