lua-users home
lua-l archive

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


In message <1144327322.44350c9a1c4e6@webmail.dnainternet.net> you wrote:
 
> My use of "integer patch" name was probably misleading, it really is
> either "non-FPU optimization 
> patch" or "integer optimization patch".
> 
> You can freely set it up in any combination of:
> - int32 / int64
> - float / double
> 
> In your situation, you'd opt for int32 and float, which both eat 32 bits.
> 
> The benefits:
> - integer speed for integer operations
> - integer precision throughout the int32 range
> - transparent int/float conversions, but only when needed
> (i.e if doing 2/3, or maxint+1)

I need the 32-bit integer arithmetic for interfacing to the OS,
and that requires the integer arithmetic to be modulo 2^32. So
0xffffffff + 1 has to be zero, not some floating point number.
The floating point numbers (modelling the reals, a field
of characteristic zero) have to be kept totally separate from
integers (modelling the ring of integers modulo 2^32). There can be
no sensible coercions between between them, seeing that
there are no homomorphisms between the rings they model.

<rant - please excuse>
Programming languages tend to serve the mathematician
poorly for coping with the infinite multiplicity of meanings that
"number" can have. No doubt there are practical advantages in
having the IEEE standards, and processors that have been intensively
developed to use them, but even for modelling real arithmetic the IEEE
formats are a few among an infinity of different possibilities, some
better for particular tasks than others. Did you know that
you can have real arithmetics that are exactly associative
(which the IEEE formats are not)? Google "Abbas Edalat" to find out.
Or you can use modular arithmetic modulo a large prime; or
lazy streams of rational Moebius transformations, .... .
I am afraid that a lot of programmers tend to dismiss arithmetic as a
bothersome technical detail, and are thankful to the cram the
whole business into the IEEE's bed of Procrustes (google if this
particular kind of bed is not familiar!). 
</rant> 
-- 
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/