[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [5.3] Converting a floating point number to integer.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 19 Nov 2014 08:23:16 -0200
> The point of my original post was that the sub-types of “number" in
> Lua 5.3 make the number type more complex than before, and that it
> *might* actually be simpler to not try to hide the sub-types inside
> number but to simply have two different types. I didn’t say it
> should be done, i was just speculating. However, I don’t see how you
> could explain my earlier example without going into the details of
> integers vs floating point, so in a way there ARE two types; they are
> just hidden within the “number” type. After all, this will require
> some explaining as well:
There ARE two subtypes, nobody is trying to hide that. They are
"grouped" inside "number", not hidden. The manual says there are two
subtypes, there are functions to distinguish them, and their values are
even printed differently.
The difference between two types and two subtypes boils down to what is
the value of "type(1) == type(1.0)". Making them different (that is, two
full types) would break a lot of code, with little gain (if any, in my
point of view).
-- Roberto