128 bit math?

B

Bruce.

MS VC Developer Studio 2003.

I have some rather large integer numbers, 128 bits, I need to crunch. I
need to be able to add, subtract, multiply, and divide. In no case would
the result exceed 128 bits. Test for equal, greater than, less than.

I would use _int128 if it existed.

The values are currently in byte arrays such as:

unsigned char value[16];

arranged little endian (least significant first).

Anyone know of a quick and easy way to do this?

Thanks,
Bruce.
 
V

Victor Bazarov

Bruce. said:
MS VC Developer Studio 2003.

That's irrelevant here, unfortunately.
I have some rather large integer numbers, 128 bits, I need to crunch.
I need to be able to add, subtract, multiply, and divide. In no case
would the result exceed 128 bits. Test for equal, greater than, less
than.
I would use _int128 if it existed.

It doesn't. We feel your pain. Next time you will need _int256 or
_int1024. It doesn't mean the language is going to have it, though.
So, you're stuck rolling your own or getting a working solution from
a third party.
The values are currently in byte arrays such as:

unsigned char value[16];

arranged little endian (least significant first).

Anyone know of a quick and easy way to do this?

Look up "arbitrary precision integer arithmetic" on the Web.

V
 
I

Ian Collins

Bruce. said:
MS VC Developer Studio 2003.

I have some rather large integer numbers, 128 bits, I need to crunch. I
need to be able to add, subtract, multiply, and divide. In no case would
the result exceed 128 bits. Test for equal, greater than, less than.

I would use _int128 if it existed.

The values are currently in byte arrays such as:

unsigned char value[16];

arranged little endian (least significant first).

Anyone know of a quick and easy way to do this?
One example that might help you is the 64 bit math routines in the GD
library source. They could be updated to do 128 bit using int64_t.
 
M

Michael Angelo Ravera

MS VC Developer Studio 2003.

I have some rather large integer numbers, 128 bits, I need to crunch. I
need to be able to add, subtract, multiply, and divide. In no case would
the result exceed 128 bits. Test for equal, greater than, less than.

I would use _int128 if it existed.

The values are currently in byte arrays such as:

unsigned char value[16];

arranged little endian (least significant first).

Anyone know of a quick and easy way to do this?

I have a set that use the arbitrary length integer math often found in
cryptography libaries. I haven't needed int256, yet. E-mail me at
michravera at yahoo dot com and we can talk.
 
B

Bruce.

Ian Collins said:
One example that might help you is the 64 bit math routines in the GD
library source. They could be updated to do 128 bit using int64_t.

Sorry, what is GD library source?

Bruce.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top