|
|
 |
 |
 |
 |
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.
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
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.
On May 29, 11:53 am, "Bruce." <n@nowhere.com> 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?
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.
"Ian Collins" <ian-n @hotmail.com> wrote in message news:5c3kmpF2ssn56U45@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.
Bruce. wrote: > "Ian Collins" <ian-n @hotmail.com> wrote in message > news:5c3kmpF2ssn56U45@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.
|
 |
 |
 |
 |
|