468,296 Members | 1,313 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,296 developers. It's quick & easy.

128 bit math?

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.
May 29 '07 #1
5 5114
Bruce. wrote:
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 29 '07 #2
Bruce. wrote:
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.

--
Ian Collins.
May 29 '07 #3
On May 29, 11:53 am, "Bruce." <n...@nowhere.comwrote:
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.
May 29 '07 #4
"Ian Collins" <ia******@hotmail.comwrote in message
news:5c**************@mid.individual.net...
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.
May 29 '07 #5
Bruce. wrote:
"Ian Collins" <ia******@hotmail.comwrote in message
news:5c**************@mid.individual.net...
>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?
Try the first hit on a google for "gd library".

--
Ian Collins.
May 29 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by Frank Millman | last post: by
reply views Thread by Jussi Mononen | last post: by
17 posts views Thread by cwdjrxyz | last post: by
7 posts views Thread by bravesplace | last post: by
110 posts views Thread by Gregory Pietsch | last post: by
11 posts views Thread by Sambo | last post: by
reply views Thread by kirby.urner | last post: by
4 posts views Thread by =?Utf-8?B?UmVuZQ==?= | last post: by
15 posts views Thread by bH | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.