[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Integers-related trap in Lua 5.3
- From: Sean Conner <sean@...>
- Date: Tue, 17 May 2016 13:11:36 -0400
It was thus said that the Great Daurnimator once stated:
> On 17 May 2016 at 12:57, Sean Conner <email@example.com> wrote:
> > You misunderstood me.
> > tonumber() always returns a double or nil if not a double
> > math.tointeger() always returns an integer or nil if not an integer
> > tonumber() isn't smart. math.tointeger() isn't smart.
> tonumber() should always parse numbers the same way lua would.
> If lua has literal integers, it should return integers
> If lua has literal doubles, it should return doubles.
That I can accept.
> This keeps identities such as tonumber(tostring(mynumber)) == mynumber
> as well as reducing surprises.
> Yes there is a math.tointeger; perhaps you also want a math.tofloatingpoint()?
Eh ... I can live without math.tofloatingpoint().
-spc (And I can live without math.tofp() as well ... )