math.ceil(x), math.floor(x), and math.trunc(x) and round(x) alreadyOn Sun, Sep 30, 2012 at 2:51 PM, Joshua Landau
<joshua.landau.ws@gmail.com> wrote:
> On 30 September 2012 22:48, Joshua Landau <joshua.landau.ws@gmail.com>
> wrote:
>>
>> This seems like a problem for the proposal, though: we can't have it in
>> the math library if it's a method!
>
>
> Now I think about it: yeah, it can be. We just coerce to float/decimal
> first. *sigh*
call the special methods x.__ceil__, x.__floor__, x.__round__, and
x.__trunc__. So those four functions already work with decimal
instances (and other numeric types that support those methods.)
>>> math.ceil("")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: a float is required