[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: math.tofloat (or how to check if number has float representation)
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Sat, 17 Jan 2015 16:49:24 -0200
> >>How do I check if x can be represented as a float? For example, for
> >>64-bit integers and 64-bit floats, (1<<62)+5 cannot be represented
> >>as a float, but 1<<62 can.
> >print(x == math.tointeger(x+0.0))
> >
> What if x is a float?
print(x == (x+0.0))
If you need to distinguish integers from float, you can use math.type(x).
But please share why you need all this.