Page 2 of 2

Re: Extended Integer Arithmetic code in PB

Posted: Sat Dec 07, 2019 11:58 am
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

Re: Extended Integer Arithmetic code in PB

Posted: Sat Dec 07, 2019 3:37 pm
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

Re: Extended Integer Arithmetic code in PB

Posted: Sat Dec 07, 2019 8:36 pm
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.