Page 2 of 4

Re: BigInt module (SSE2)

Posted: Mon Mar 28, 2016 11:20 am
by walbus
Great !

Re: BigInt module (SSE2)

Posted: Sun Oct 09, 2016 5:34 pm
by Crusiatus Black
My apologies for the bump. On Linux (Mint x64) and PureBasic 5.42 x64 BigInt operations stall execution (it stops). When LoadValue is called.

Code: Select all

      Debug "loading value...."
      BigInt::LoadValue(*n, *RandN, ByteSize, #True)
      Debug "loaded value..."
*RandN is just a buffer with random memory.

The exact same code works perfectly fine on Windows x64 and x86.

Scratch that, it was caused by a stack corruption in another library. When isolated, this code runs fine.

Re: BigInt module (SSE2)

Posted: Mon Oct 10, 2016 5:46 am
by wilbert
Crusiatus Black wrote:Scratch that, it was caused by a stack corruption in another library. When isolated, this code runs fine.
That explains why I couldn't replicate the problem.
Anyway, glad to hear it works fine after all :)

Re: BigInt module (SSE2)

Posted: Mon Oct 10, 2016 7:30 am
by Crusiatus Black
wilbert wrote:
Crusiatus Black wrote:Scratch that, it was caused by a stack corruption in another library. When isolated, this code runs fine.
That explains why I couldn't replicate the problem.
Anyway, glad to hear it works fine after all :)
Ah sorry, I didn't mean to give you unnecessary work. Now for me a challenge, how to find the stack issue that only occurs on Linux...

Re: BigInt module (SSE2)

Posted: Mon Oct 10, 2016 7:41 am
by wilbert
Crusiatus Black wrote:Ah sorry, I didn't mean to give you unnecessary work. Now for me a challenge, how to find the stack issue that only occurs on Linux...
No problem and good luck with tracking down the stack issue.
It can be difficult sometimes to solve something which is only happening on one OS.

Re: BigInt module (SSE2)

Posted: Mon Oct 10, 2016 7:55 am
by Crusiatus Black
wilbert wrote:
Crusiatus Black wrote:Ah sorry, I didn't mean to give you unnecessary work. Now for me a challenge, how to find the stack issue that only occurs on Linux...
No problem and good luck with tracking down the stack issue.
It can be difficult sometimes to solve something which is only happening on one OS.
Thank you! Yes, the purifier told me about the stack issue on Linux, however on Windows the purifier is quiet.

The programming life is a magical life.

Re: BigInt module (SSE2)

Posted: Mon Jan 01, 2018 11:40 am
by NicknameFJ
Hello Wilbert,

first I wish you a happy new year 2018.

Thank you for sharing your BigInt-Lib.

Maybe I´am doing something wrong with it, maybe there is an error in it.

Run this short prg and it will crash with an Stack Overflow Error. I´m on Windows 10 with PB 5.61 x64.

It is always wenn the result of a^b mod(c) is zero. The same happens when using the ModMul-Funktion and the result of a * b mod(c) is zero too. I think the error is in your procedure divmod_private procedure because this proc is called in both; if I comment the call of divmod_privat out, sure the result ist wrong when doing so, but no crash at all.

Maybe I´m doing something wrong with it. In this case it would be nice when you can tell me what I´m doing wrong.

Maybe you can take a look because I don´t understand your great code so I can not fix it by myself.

Thank you

NicknameFJ

Code: Select all

IncludeFile "O:\Includes\BigInt\BigInt.pbi" 

Define.BigInt::BigInt X, A, B, C


BigInt::SetValue(A,12)
BiGInt::SetValue(B,13)
BiGInt::SetValue(C,27)


BIGInt::ModPow(X,A,B,C)

Re: BigInt module (SSE2)

Posted: Tue Jan 02, 2018 8:55 am
by wilbert
NicknameFJ wrote:Maybe I´am doing something wrong with it, maybe there is an error in it.

Run this short prg and it will crash with an Stack Overflow Error. I´m on Windows 10 with PB 5.61 x64.
I made a small change to the module code in the first post.
Can you check if it works fine now ?

Re: BigInt module (SSE2)

Posted: Tue Jan 02, 2018 6:12 pm
by NicknameFJ
Hello wilbert,

after a few short tests it seems to work fine.


Thank you very very much for your answer and for fixing it so fast.

When we ever met tell me that you are wilbert and I will spend you one beer, or two, or three ..... :D


NicknameFJ

Re: BigInt module (SSE2)

Posted: Sun Jan 07, 2018 4:42 pm
by Michael Vogel
Great stuff, thanks to wilbert and little john!

Combining the Radi and BigInt modules allow wonderful calculations, like the old calculator precision test to repeat x^2 26 times starting with the value 1.0000001

Code: Select all

z=Radi::MaxDestDigits(BigInt::#BigIntBits,2,10)
Debug "A binary number with "+Str(BigInt::#BigIntBits)+" digits has up To "+Str(z)+" decimal digits"

z=z/2
BigInt::SetValue(n1,10000001)
For i=1 To 26
	BigInt::Multiply(n1, n1)
	s.s=Left(Radi::Hex2Dec(BigInt::GetHex(n1)),z)
	BigInt::SetHexValue(n1,Radi::Dec2Hex(s))
Next i

Debug Radi::Hex2Dec(BigInt::GetHex(n1))

Re: BigInt module (SSE2)

Posted: Fri Nov 05, 2021 11:59 am
by CELTIC88
Wonderful. :shock:

Re: BigInt module (SSE2)

Posted: Tue Dec 21, 2021 6:23 pm
by jack
hello wilbert :)
do you have a non-asm version?
could be useful for trying out on the C back-end
btw, I came across this document about arbitrary precision arithmetic algorithms with test-code in fortran https://ia800403.us.archive.org/10/item ... 9.5911.pdf

Re: BigInt module (SSE2)

Posted: Tue Dec 21, 2021 6:41 pm
by wilbert
jack wrote: Tue Dec 21, 2021 6:23 pm hello wilbert :)
do you have a non-asm version?
Sorry, I don't.
At the time I didn't think about the possibility of PB running on something other than x86 / x64.

Re: BigInt module (SSE2)

Posted: Tue Dec 21, 2021 9:05 pm
by AZJIO
I added this to the help file (ru)

Re: BigInt module (SSE2)

Posted: Thu Dec 30, 2021 7:31 pm
by Kwai chang caine
Useful funstion
Works here :D
121FA000A3723A57C24A442FE55618CF
1234567890ABCDEF
Thanks for sharing 8)