[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: integer exponentiation with negative exponent
- From: Leo Razoumov <slonik.az@...>
- Date: Fri, 16 May 2014 21:43:19 -0400
On 4/29/14, Tim Hill <firstname.lastname@example.org> wrote:
> “I agree with the original rationale (as outlined by Roberto, with some
> reservations) that only the types of values affect the outcome, not the
In math the type of a result of a numeric operation DOES depend on the values
of the operands because some arithmetic operations (notably division)
are not closed in integers.
For example, take division: 4/2 == 2: two integers go in and one
integer goes out and all the math properties of division
are preserved. On the other hand, 5/3 poses a problem. You either
perform a floating point division which changes
the type, or preserve the type by doing an integer division which
breaks associativity of the division.
If you insist you can have full type consistency but then do not call
them the arithmetic operations.
By demanding type invariance one goes back to the arithmetic model of C
where you have to carefully track the numeric types.
Lua has a simple and consistent math based upon a single numeric type
-- 64-bit float.