473,320 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
7 4901
"Bruce." <no***@nowhere.comwrites:
>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?

By treating the arrays as pairs of int64_t's ?
When 64-bit machines were far less common, many used a library developed
by Netscape to support 64-bit arithmetic using arrays of two 32-bit numbers.
It was supported by a header file of prototypes and macros to account for
endianness concerns.
I suspect that much of that code could be reused for your application.

--
Chris.
May 29 '07 #2
"Chris McDonald" <ch***@csse.uwa.edu.auwrote in message
news:f3**********@enyo.uwa.edu.au...
By treating the arrays as pairs of int64_t's ?
When 64-bit machines were far less common, many used a library developed
by Netscape to support 64-bit arithmetic using arrays of two 32-bit
numbers.
It was supported by a header file of prototypes and macros to account for
endianness concerns.
I suspect that much of that code could be reused for your application.
Any idea where I might find that code?

Bruce.
May 29 '07 #3
Bruce. wrote:
MS VC Developer Studio 2003.
Please don't multi-post on Usenet. Cross-post if you think your
question is really appropriate for more than one group.

--
Ian Collins.
May 29 '07 #4
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?

Thanks,
Bruce.

Use lcc-win32, it provides 128 bit numbers in the standard
distribution

http://www.cs.virginia.edu/~lcc-win32
May 29 '07 #5
On May 30, 7:31 am, jacob navia <j...@jacob.remcomp.frwrote:
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?
Thanks,
Bruce.

Use lcc-win32, it provides 128 bit numbers in the standard
distribution

http://www.cs.virginia.edu/~lcc-win32
Dear Bruce,

Please try Intel 128 bit instruction(SSE /2/3) and 128 bit
registers(XMM registers). You can use these instructions for 128 bit
arithmetic. PADD*, PMUL* PSUB* etc are some of the instruction
samples. Even AMD processors have these kind instructions. Please read
the instructions manuals.

Use _asm block to right assembly in VC2003.

Thanks and regards,
Amal P.

May 30 '07 #6
There is a library available called GMP. It allows you to deal with
integers of arbitrary precision (reals and rationals too).

Here's the URL: http://gmplib.org/

Regards
Chris Saunders

<en********@gmail.comwrote in message
news:11**********************@z28g2000prd.googlegr oups.com...
On May 30, 7:31 am, jacob navia <j...@jacob.remcomp.frwrote:
>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?
Thanks,
Bruce.

Use lcc-win32, it provides 128 bit numbers in the standard
distribution

http://www.cs.virginia.edu/~lcc-win32
Dear Bruce,

Please try Intel 128 bit instruction(SSE /2/3) and 128 bit
registers(XMM registers). You can use these instructions for 128 bit
arithmetic. PADD*, PMUL* PSUB* etc are some of the instruction
samples. Even AMD processors have these kind instructions. Please read
the instructions manuals.

Use _asm block to right assembly in VC2003.

Thanks and regards,
Amal P.

May 30 '07 #7
"Chris Saunders" <ev**@mountaincable.netwrote in message
news:1f***************************@MOUNTAINCABLE.N ET...
There is a library available called GMP. It allows you to deal with
integers of arbitrary precision (reals and rationals too).

Here's the URL: http://gmplib.org/
Thanks for the link. I'll check that out.

Bruce.
May 30 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Frank Millman | last post by:
Hi all I was helping my niece with her trigonometry homework last night. Her calculator's batteries were flat, so I thought I would use Python's math module to calculate sin, cos, and tan. I...
0
by: Jussi Mononen | last post by:
Hi, I'm having problems to successfully execute the test scripts on a Compaq host ( OSF1 tr51bdev V5.1 2650 alpha ). Almost all tests end up with the following error message "PARI: *** ...
1
by: limelight | last post by:
I have discovered a math error in the .NET framework's Log function. It returns incorrect results for varying powers of 2 that depend on whether the program is run from within the IDE or from the...
17
by: cwdjrxyz | last post by:
Javascript has a very small math function list. However there is no reason that this list can not be extended greatly. Speed is not an issue, unless you nest complicated calculations several levels...
7
by: bravesplace | last post by:
Hello, I am using the folling funtion to round a number to a single digit on my form: function round1(num) { return Math.round(num*1)/1 }
110
by: Gregory Pietsch | last post by:
I'm writing a portable implementation of the C standard library for http://www.clc-wiki.net and I was wondering if someone could check the functions in math.h for sanity/portability/whatever. I'm...
11
by: Sambo | last post by:
I have the following module: ------------------------------- import math def ac_add_a_ph( amp1, ph1, amp2, ph2 ): amp3 = 0.0 ph3 = 0.0 ac1 = ( 0, 0j ) ac2 = ( 0, 0j )
0
by: kirby.urner | last post by:
Cyber-curricula have a leveling aspect, as kids nearer Katrina's epicenter tune in and bliss out on 'Warriors of the Net' (why wait for stupid big dummy textbooks to catch up?). They feel more...
4
by: =?Utf-8?B?UmVuZQ==?= | last post by:
Hello everyone I have a problem with Math.Round, it´s ocurring some strange: Math.Round(12.985) = 12.98, it´s wrong. It should be: 12.99 Why?? What is the problem? Help ME !!!!
15
by: bH | last post by:
Hi All, I have been looking at javascript drawing from this website : http://www.cwdjr.net/geometricDraw/pentagon_draw.html" and I am wondering why the author made it into two images : upper...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.