lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 1 March 2013 09:40, Christopher Berardi <cberardi@natoufa.com> wrote:
> So shall we ignore all the irrational numbers? No PI, sqrt(2), etc.?
>
> I would welcome distinct number types (e.g., real, integer). But, if we must
> use a single number type I would like it to work in the following manner. A
> single number type would be comprised of 3 different types (C union?). If the
> number can be represented as an integer, then it is an integer type. If the
> number cannot be represented as an integer, then it is a real/double type. If
> the number is too big for either an integer or a double, then it it a bignum
> (i.e., arbitrary precision) type. From the lua programmers point of view, there
> is only a single number type and the determination of what type of number it is
> (e.g., integer, double, bignum) would be the responsibility of the VM as well
> as the proper working of the operators (e.g., +,-,*,/,etc.) Though, I don't
> know how easy or simple that would be implemented?
>
> --
> Christopher Berardi
> May grace and peace be yours in abundance.
>

That's pretty much what ruby does.
One of the main reasons we don't do this in lua is the size of a
bignum library: AFAIK it's likely to massively increase the size of
the lua source.