Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (684) Games in Android Showcase (196) games submitted by our members Games in WIP (751) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Home Help Search Login Register
Pages: [1]
 ignore  |  Print
 256 Math library is done.  (Read 3203 times) 0 Members and 1 Guest are viewing this topic.
Raghar

Junior Devvie

Ue ni taete 'ru hitomi ni kono mi wa dou utsuru

 « Posted 2005-09-27 18:59:43 »

I finally done a library for Java with support of 256 bit integer arigthmetic, and other operations. Actually I did also 128 bit one.  These have support for both signed and unsigned numbers.
So some results

add 101 - 150 ms
sub simillar
div  between 10 s - 19 s
mul 1300 ms

All tested for 1000000 itereations.  Thus for example add is aprox up to 250 cycles.

I know I should post it in anoncements, but I would like to know if I didn't missed any algorithms that could speed things up.
Mark Thornton

Senior Devvie

 « Reply #1 - Posted 2005-09-28 07:52:26 »

Rather hard to know if you have missed any better algorithms without knowing which ones you have actually used. It certainly possible to improve on the classical algorithms for multiplication and division.
Raghar

Junior Devvie

Ue ni taete 'ru hitomi ni kono mi wa dou utsuru

 « Reply #2 - Posted 2005-09-28 14:52:09 »

For multiplication, I used the standard algorithm

q[0] = a[0] * b[0]

q[1] = a[0] * b[1] + a[1] * b[0]

and so on

For example 10 * 22
q[0] = 0 * 2
q[1] = 0 *2 + 1 * 2
...

For division, I used the algorithm with a subtraction and a bitshift.
 Games published by our own members! Check 'em out!
Mark Thornton

Senior Devvie

 « Reply #3 - Posted 2005-09-28 15:18:10 »

Have a look at section 4.3.3 of Knuth's "The Art of Computer Programming" volume 2 (Seminumerical Algorithms).
pepijnve

Junior Devvie

Java games rock!

 « Reply #4 - Posted 2005-09-29 07:58:46 »

I'm probably missing the point, but doesn't BigInteger cover this stuff already?
Mark Thornton

Senior Devvie

 « Reply #5 - Posted 2005-09-29 13:05:24 »

I'm probably missing the point, but doesn't BigInteger cover this stuff already?
The point would be performance. Is it possible to create a class that, for 256 bit values, is significantly faster than BigInteger?
pepijnve

Junior Devvie

Java games rock!

 « Reply #6 - Posted 2005-09-29 13:20:04 »

The point would be performance.
Why didn't I think of that?

Is it possible to create a class that, for 256 bit values, is significantly faster than BigInteger?
That was kind of my next question. How do those performance figures compare to doing the same thing with BigInteger?

Edit:
It might also be intersting to compare against other math libs like apfloat (first one I encountered while googling on BigInteger performance).
Raghar

Junior Devvie

Ue ni taete 'ru hitomi ni kono mi wa dou utsuru

 « Reply #7 - Posted 2005-09-29 22:52:26 »

In comparison to the MutableBigInteger? Dunno multiplication would be same. MutableBigInteger is spawning new array for outcome, while my library doesn't create any new object after inicialization.
I have better subtraction, because MutableBigInteger used too much mathematically rigorous algorithm.

The biggest problem with these libraries is, they can't access carry flag from Java. So they are running sometimes at half speed.
Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 orrenravid (228 views) 2016-07-16 03:57:23 theagentd (296 views) 2016-07-11 14:28:54 Hydroque (383 views) 2016-07-06 05:56:57 Hydroque (534 views) 2016-07-03 08:52:54 GrandCastle (404 views) 2016-07-01 09:13:47 GrandCastle (398 views) 2016-07-01 09:09:45 CopyableCougar4 (450 views) 2016-06-25 16:56:52 Hydroque (422 views) 2016-06-22 02:17:53 SwampChicken (387 views) 2016-06-20 13:22:57 SwampChicken (306 views) 2016-06-20 13:22:49
 Archive 30x Slyth2727 24x Brynn 23x EgonOlsen 22x orangepascal 22x TritonDreyja 21x orange451 20x DavidBVal 19x Spasi 18x LiquidNitrogen 11x Phased 11x Opiop 11x princec 11x Longor1996 10x ziozio 10x KaiHH 10x
 Making a Dynamic Plugin Systemby Hydroque2016-06-25 00:13:25Java Data structures2016-06-13 21:22:09Java Data structures2016-06-13 21:20:42FPS Camera Tutorialby Hydroque2016-05-22 05:40:58Website offering 3D Models specifically for games for freeby vusman2016-05-18 17:23:09Website offering 3D Models specifically for games for freeby vusman2016-05-09 08:50:56Website offering 3D Models specifically for games for freeby vusman2016-05-06 11:10:21Website offering 3D Models specifically for games for freeby vusman2016-04-29 12:56:17
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org