lua-users home
lua-l archive

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


On Fri, Mar 1, 2013 at 1:40 AM, Christopher Berardi
<cberardi@natoufa.com> wrote:
> 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.)

I like this idea very much.
Number is pure math object, it cannot be 'integer" of "float".
Operations on numbers may be "integer"-type or "real"-type, but not
numbers itself.
Numbers can be stored in computer memory in different ways,
but only one "number" data type should be exposed to programmer.
Moreover, ideal implementation of numbers should have possibility to store
numbers as functions, which would calculate any digit of the number on demand.
So, all numbers including pi, sqrt(2), ln(10) would have unlimited precision.