Extended Integer Arithmetic code in PB

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
Etayson
Enthusiast
Enthusiast
Posts: 110
Joined: Sun Jun 05, 2016 5:01 pm

Re: Extended Integer Arithmetic code in PB

Post by Etayson »

code give invalid result or error
Check it:

Code: Select all

Define test.XI, test2.XI, test3.XI, test4.XI
ValXI("-6648017327330721573130469691821214539915264646577269269561",@test)
ValXI("115792089237316195423570985008687907853269984665640564039457584007908834671663",@test2)
DivXI(@test,@test2,@test3,@test4)
Debug StrXI(@test3)
error in line 346: TempS = *Dvisor\Ra(X) - *Res\Ra(X - Diff) - Carry
because Diff = *Dvisor\NumOfLimbs - *Res\NumOfLimbs set to 2
and when x=1 we get error out of bonds

and some function like GreaterThanXI... work incorrect like:

Code: Select all

ValXI("-7",@test)
ValXI("-8",@test2)
Debug GreaterThanXI(@test,@test2)
End
-7 should be >-8 but return 0
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Extended Integer Arithmetic code in PB

Post by davido »

@Etayson,
I wrote that program for my own purposes as I could not find anything else in Pure Basic code.
That situation changed when an alternative was written by wilbert. I now use that code.
There is simply no contest as wilbert's code is superior in every respect. See url below:
viewtopic.php?p=458493#p458493


Another good alternative is a 'wrap' of GMP 6.0 by bbanelli, see url below:
viewtopic.php?p=458533#p458533
DE AA EB
Etayson
Enthusiast
Enthusiast
Posts: 110
Joined: Sun Jun 05, 2016 5:01 pm

Re: Extended Integer Arithmetic code in PB

Post by Etayson »

davido wrote:@Etayson,

Another good alternative is a 'wrap' of GMP 6.0 by bbanelli, see url below:
viewtopic.php?p=458533#p458533
Thank you for answer. For my job seems like mpz will be the best choice.
Post Reply