Python rounding up float number -
this question has answer here:
- limiting floats 2 decimal points 16 answers
i need results these:
2.1421 => 2.15 2.1401 => 2.15 2.14 => 2.14
as @jerrybibo mentioned, you'll need use ceil function, , result nearest hundredths place, multiply number hundred, run through ceil , divide answer 100. can try in idle.
>>> math.ceil(2.1421 * 100) / 100 2.15
hope helps.
Comments
Post a Comment