Python 3 rounding behavior in Python 2 -
In Python 2.x, the following behavior has the following:
If two multiplier equals The form is closed, the spherical is away from 0 (for example, the goal is 0.5) 1.0 and the round (-0.5) -1.0)
In Python 3.x, more general:
If two factors are evenly closed, then the spherical is also preferred (hence, example For, both rounds (0.5) and goals (-0.5) are 0, and the round (1.5) is 2).
Is this an easy way to get this behavior in Python 2.x? Unfortunately, this is not included in the module. Maybe there's another similar module that I have not yet received? Or, another way to drag Python 3.x functions into Python 2.x?
Obviously, I can write a new function that generates the desired behavior, but if there is a solution, I'm curious to use it. The real Python 3.x function, unnecessary complexity and code To avoid retaining
An odd dependency, this can work:
Gt; & Gt; & Gt; Eggs around imports & gt; & Gt; & Gt; About (0.5) 0 >> gt; & Gt; Around (-0.5) -0> & Gt; & Gt; Approximate (1.5) 2.0
Comments
Post a Comment