Hgh precision arithmetic in Java.

So I went into a nice problem of additing a some high precision number cababilities to the Java.

Namely 128 bit primitives, 256 bit primitives, and unlimited depth precision.
I already discovered why Intel preffers high endian, better for multiplying and forward iteration during addition.

IIRC SSE2 registers don’t support carry flag (or adc), so I might be forced to use a slighly less efficient algorithm for parallel computation.

This library seems to look interesting. It’s backed by byte arrays (could hotspot translate (a &0xff)*b(&0xff) to mul eax, ebx ?) I have also a nice asm code sniplets for addition of full native support to the hotspot under MMX compatibile IA32 platforms.

So whats are your thoughts on Java supporting 128 bit numbers natively?

We talking int or float ?

For int BigInt has existed for quite ahwile.

Actually both.

Note I talked about 128 bit and 256 bit primitives. BigInt isn’t exactly what you’d like to use for fixed size arithmetic when you would like to have data in one place of memory for a long time.

Java has a high precision library, with support for high precision arithmetic, and some other features. Like endian independence, and ability to work with buffers.

Funny thing is it’s curently not exactly usable for my purposes. And benchmarks showed it’s 29 x slower for int multiplication, and 300 times slower for 16 byte multiplication than standard int multiplication on 32 bit computer. It’s not exactly bad and for things that needs such precision it’s better than nothing.
Interface is nice, and prety much usable with future versions of simillar libraries.