Integer Maths -- please deliver us from 'em...

Eugene Leitl (Eugene.Leitl@lrz.uni-muenchen.de)
Fri, 29 Nov 1996 16:18:47 +0100 (MET)


On Fri, 29 Nov 1996, Wayne Morellini wrote:

> 
> 
> Hi none of my cursor keys work at the moment so forgive the mistakes.
> 
> I was just thinking last night why we need floating piontg maths.

Why, indeed? Currently, I am reading "High Performance Computing", an 
O'Reilly book. It discusses some of the float's convenience, aka 
difficult-to-detect numerical bugs. I think "Numerical recipes" talks 
about this as well.
 
> I realised that our big problem is that we tend to base the computers work
> pattern (instruction set) on the human form rather than what is fastest,
> like Forth.

Early computers used scaled integers, to be scaled by the programmer. 
Floating point numbers are nothing else that automagically scaling 
integers. Convenience, dearly bought.

> Chuck I've read in the past has stated that he did not included floating
> piont maths because it wasn't needed, I know what he means.

Indeed. But try telling to the average numeric modeler "You don't need 
floats, if only integers are broad enough (let's say 128 bits)". Rofl, 
that what he'll do.
 
> The amount of chip realestated wasted on floating point operations is
> staggering, apart from caching most of the rest goes to this function from

Agreed. One crucial point: maspar machines, made from CPU's with on-die 
RAM and routers cannot be implemented on dies beyond certain size (bad 
die yield goes up exponentially with die size), so very primitive CPU's 
will be needed. No cache. No pipeline. No BPU. No FPU. No bells & 
whistles. Consider a 128-node machine, with each node having just 128 
kBytes, max 256 kBytes DRAM.

This spells nanokernel. This spells OOP, and threaded code, to increase 
code density. This spells a stack machine. This spells MISC, which will 
resemble the yet-to-come P32 very closely.

The future is MISC, specifically Moore technology. (The only problem: the 
future still does not know it. Mr. Amazing Moore has got a marketing 
problem. Let's hope the Pegasus box will make it).

> what I've seen.  So what do we do with the floating piont equations in
> science, simple work them in interger form and at the end when the result
> comes toi the screen translate them to floating piont (Well what I think).

There is a problem: integers have a constant mapping density to reals, 
while floats do not. Floats feature much larger dynamic range, which is 
crucial for some scientific numerical code. We'd need 128 bit integer 
ALUs to truly beat floats everywhere.
 
> For instance what if we present numbers as fractions (rations) one dleving
> into other black arts when the need to be presented?  I was think lasty

No, lots of code exists. I saw some of basic stuff in Abelson & Sussman's 
Wizard book (Structure & Interpretation of Computer Programs).

> night about doing 3 dimensional grapics integerally.  I though up scheemes
> for drawing lines etc with integers and then I thought but how do I sczale

You don't even need integers. You can do much faster by using masks and 
lookups. You can draw lines as fast as the video memory bandwidth lets 
you.

Even FPU's use look-up for transcendents to have a head start in the 
iteration. Much can be done with simple logics, shifts and lookups. 
Lacking massive ALU support, this is the only way to code on Chuck's 
chips. The only feature I am missing is a barrel shifter, and some 
opcodes to drive it.

> them to different screen sizes.  Well the intersting thing is that if I had
> a 256 pixel wide screen and wanted to scale to a 16 pixel screen all I would

Yes, binary bitmap sizes are extremely efficient. I have noticed that 
almost a decade ago. But we had to stick to this idiotic PAL/NTSC 
standards, and virtual desktops (hardware scroll) became mainstream only 
relatively recently.

> have to do was drop the lower 4 bits and move the upper ones down.  Now if I
> wanted to do anti-aliasing if could use the lower 4 bits to determine the
> way the pixel blending in with the surrounding pixels and so forth :).  But
> of course this only works easily because they are whole bin ary numbers.
> 
> Has anybody out there dwelved into 3-D graphics with integer structures,
> that can help me.

Have a look at raycasting algorithms, instances of which can be seen in 
Doom and Quake. Search for mars.zip on the net, this one illustrates some 
of the basic concepts on a minimalistic example.

> I am thinking that ordinary integer maths might be all that is required?

Yep. Agree absolutely. But gimme broad integers, please.

'gene

> 
> Wayne.
> -- 
> 
> 

____________________________________________________________________________
|mailto:ui22204@sunmail.lrz-muenchen.de|transhumanism >H, cryonics,        |
|mailto:Eugene.Leitl@uni-muenchen.de   |nanotechnology, etc. etc.          |
|mailto:c438@org.chemie.uni-muenchen.de|"deus ex machina, v.0.0.alpha"     |
|icbmto:N 48 10'07'' E 011 33'53''     |http://www.lrz-muenchen.de/~ui22204|