By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,515 Members | 1,772 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,515 IT Pros & Developers. It's quick & easy.

128 bit math?

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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.