Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (407)
games submitted by our members
Games in WIP (293)
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 2139 times)
0 Members and 1 Guest are viewing this topic.
Offline Raghar

Junior Member




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


« Posted 2005-09-27 20: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.
Offline Mark Thornton

Senior Member





« Reply #1 - Posted 2005-09-28 09: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.
Offline Raghar

Junior Member




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


« Reply #2 - Posted 2005-09-28 16: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!
Play the free demo of Revenge of the Titans!
Offline Mark Thornton

Senior Member





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

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

Junior Member




Java games rock!


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

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

Senior Member





« Reply #5 - Posted 2005-09-29 15: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?
Offline pepijnve

Junior Member




Java games rock!


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

The point would be performance.
Roll Eyes 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).
Offline Raghar

Junior Member




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


« Reply #7 - Posted 2005-09-30 00: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.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (86 views)
2013-05-17 21:29:12

alaslipknot (94 views)
2013-05-16 21:24:48

gouessej (126 views)
2013-05-16 00:53:38

gouessej (119 views)
2013-05-16 00:17:58

theagentd (129 views)
2013-05-15 15:01:13

theagentd (116 views)
2013-05-15 15:00:54

StreetDoggy (160 views)
2013-05-14 15:56:26

kutucuk (182 views)
2013-05-12 17:10:36

kutucuk (182 views)
2013-05-12 15:36:09

UnluckyDevil (189 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.076 seconds with 21 queries.