1

Here is the issue:

>>> 16/float(1184000)

returns:

1.3513513513513513e-05

if I try to run math.ceil on this number, i get "1" instead of "2"

>>>math.ceil(16/float(1184000))

returns:

1.0

This seems odd, any ideas how to address this?

downbySF
  • 141
  • 1
  • 1
  • 11
  • 1
    I apologize if you already know this, but your first result is expressed in [**scientific notation**](http://en.wikipedia.org/wiki/Scientific_notation). 1.351e-05 can also be written as 0.00001351. And `ceil(0.00001351)` is, in fact, `1`. – jedwards Jun 19 '13 at 23:44

2 Answers2

2

Seems like you missed the power : -05:

The number is actually:

>>> '{:.20f}'.format(16/float(1184000))
'0.00001351351351351351'

So the answer is correct.

Ashwini Chaudhary
  • 244,495
  • 58
  • 464
  • 504
2

The number 1 is the smallest integer larger than 16/1184000. That's what math.ceil() does.

1.3513513513513513e-05 is between 0 and 1, so your two answers are consistent.

The number above is read as "1.3513513513513513 times 10 to the negative 5th power."

John
  • 15,990
  • 10
  • 70
  • 110