Can someone give me an example on how I can work with lets say a 100 bit number?

Using floats i know i can work with upto 80 bit numbers, but what if i have something larger, how do I perform calculations with those?

Using floats i know i can work with upto 80 bit numbers, but what if i have something larger, how do I perform calculations with those?

In algorithms I have a post with a link to GMP. It's written in C/ASM for every platform but allows for high precision, such as 256 or custom defined precision (that I'm aware of). It's very fast and efficient and works with integers and floats and so on... it's freeware open source, that means free speach and free beer... as they say...

Thanks,

_Shawn

Thanks,

_Shawn

Think about basic math...

Each DWORD becomes a unit, like each digit in a big number. If you can do 5 x 5 = 25, then you can do 5555 x 5555. It is no different when programming - break the problem into smaller pieces. Here is add:

Each DWORD becomes a unit, like each digit in a big number. If you can do 5 x 5 = 25, then you can do 5555 x 5555. It is no different when programming - break the problem into smaller pieces. Here is add:

```
AddBigNum PROC uses ebx, BigNum1:DWORD, BigNum2:DWORD, BigNumSize:DWORD
```

mov ecx,BigNumSize

mov ebx,BigNum2

mov edx,BigNum1

clc ;clear carry flag

@@: mov eax,[ebx + ecx * 4]

adc [edx + ecx * 4],eax

dec ecx ; doesn't effect carry flag

jns @B

ret

AddBigNum ENDP

I have a nice general multiply around somewhere, too? ;)Shawn thanks for the link :alright:

bitrake,

i am testing the proc you wrote but it crashes. here is what i have:

push 2h

push 12345678h

push 0ABABABABh

call AddBigNum

push 0

call ExitProcess

;#############################################################################

AddBigNum PROC uses ebx, BigNum1:DWORD, BigNum2:DWORD, BigNumSize:DWORD

mov ecx,BigNumSize

mov ebx,BigNum2

mov edx,BigNum1

clc ;clear carry flag

@@: mov eax,

adc ,eax

dec ecx ; doesn't effect carry flag

jns @B

ret

AddBigNum ENDP

;#############################################################################

it crashes at the command mov eax, because , of what i 've found out, it tries to mov the value of the address cs:12345678. Is this what it was suppose to do?? I am using masm package btw..

bitrake,

i am testing the proc you wrote but it crashes. here is what i have:

push 2h

push 12345678h

push 0ABABABABh

call AddBigNum

push 0

call ExitProcess

;#############################################################################

AddBigNum PROC uses ebx, BigNum1:DWORD, BigNum2:DWORD, BigNumSize:DWORD

mov ecx,BigNumSize

mov ebx,BigNum2

mov edx,BigNum1

clc ;clear carry flag

@@: mov eax,

adc ,eax

dec ecx ; doesn't effect carry flag

jns @B

ret

AddBigNum ENDP

;#############################################################################

it crashes at the command mov eax, because , of what i 've found out, it tries to mov the value of the address cs:12345678. Is this what it was suppose to do?? I am using masm package btw..

and if yer going to multiply, its like on school on a paper decimal:

.24

.33

.---- *

.72

720

------ +

792

you see? every round you shift the answer to the left like you learned (i guess ;). binary the same

........1011

........1100

......-- ------

......00000

....000000

..1011000

10110000

------------- +

00010111

etc. simple erh?

.24

.33

.---- *

.72

720

------ +

792

you see? every round you shift the answer to the left like you learned (i guess ;). binary the same

........1011

........1100

......-- ------

......00000

....000000

..1011000

10110000

------------- +

00010111

etc. simple erh?

Ray, it probably crashes because you pass 2 as the size of the numbers when infact they're both dwords so you should pass 1. Secondly your trying to pass the actual values, you have to pass pointers to them.

bitRAKE, I was only just going to write some routines todo just this, I'll probably do it as a learning experince to learn mmx, see if that speeds it up. However I'd be very intrested in see that multiplication code if you have it.

bitRAKE, I was only just going to write some routines todo just this, I'll probably do it as a learning experince to learn mmx, see if that speeds it up. However I'd be very intrested in see that multiplication code if you have it.

**E?in**, I couldn't get MMX to do MUL in this way, if you figure it out I'd sure love a *hint*. :) I'll find that proc, it's another nice example of recursion.

**Ray**, you have to pass pointers to the numbers:

MyFirstNum dd 1,0,0,0 ;Very Big Number

MySecondNum dd 0,0,0,1 ;Very Small Number

; the size is 0 based, pass 3 for 4 dwords size

invoke AddBigNum, ADDR MyFirstNum, ADDR MySecondNum, (LENGTHOF MyFirstNum) - 1

For those interested, THIS (apfloat) looks like a good library.

thank you