Pelican Parts
Parts Catalog Accessories Catalog How To Articles Tech Forums
Call Pelican Parts at 888-280-7799
Shopping Cart Cart | Project List | Order Status | Help



Go Back   Pelican Parts Forums > Miscellaneous and Off Topic Forums > Off Topic Discussions


Reply
 
LinkBack Thread Tools Rate Thread
Author
Thread Post New Thread    Reply
Registered
 
id10t's Avatar
 
Join Date: Mar 2003
Posts: 10,322
programmers - very large numbers and c++

Anyone have a link to a library, etc. for working with very large numbers? Think squaring a 32 bit number, square rooting a 64 bit number, etc.

Can work with MS/Visual Studio or preferably with GCC/G++

Thanks!

__________________
“IN MY EXPERIENCE, SUSAN, WITHIN THEIR HEADS TOO MANY HUMANS SPEND A LOT OF TIME IN THE MIDDLE OF WARS THAT HAPPENED CENTURIES AGO.”
Old 10-13-2010, 07:51 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #1 (permalink)
B58/732
 
BlueSkyJaunte's Avatar
 
Join Date: Feb 2000
Location: Hot as Hell, AZ
Posts: 12,313
Like GMP? The GNU MP Bignum Library
__________________
ΜΟΛΩΝ ΛΑΒΕ
I don't always talk to vegetarians--but when I do, it's with a mouthful of bacon.
Old 10-13-2010, 07:57 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #2 (permalink)
Registered
 
Rob Channell's Avatar
 
Join Date: Feb 2004
Location: Decatur/Madison, Alabama
Posts: 1,192
The 32 bit Microsoft Visual Studio compilers can do floats or doubles right out of the box. Floats are 32 bit and the doubles are 64 bit. 64 bit seems to be enough precision for most calculations. The max value for a 32 bit float is 3.4*10e38 and the max value for a double is 1.7*10e308. How big of a number do you need?

Other libraries are geared toward very large numbers such as used in computing pi to 1 billion digits or prime number searches, etc. I think some of these libraries are referred to as arbitrary precision libraries because you can choose how many digits of precision the library will provide. It all costs in terms of memory and speed.

If you are currently using float type variables in the C/C++ code then try changing them to a double and see if you get the response you would like. don't forget to take into account the change in size of any data structures using these types. It can mess you up with pointers and such depending on how the current code is written to access the data structures.
__________________
Rob Channell
One Way Motorsports
1979 911SC mostly stock
1972 911T Targa now with a good 2.7
1990 Miata (cheap 'n easy)
1993 C1500 Silverado (parts getter)
Old 10-13-2010, 06:37 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #3 (permalink)
Registered
 
Join Date: Jan 2008
Location: NW Ohio
Posts: 293
Send a message via AIM to DavidB911
We were always told to convert it to a number between 0 and 10. Then you can multiply the number of decimals needed. Say if its "1234" being squared it would be:

(1234)^2 = 1522756

Divide 1234 by 1000, then square 1.234. Multiply the answer by 1e6 to get 1522756.
Old 10-13-2010, 11:46 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #4 (permalink)
canna change law physics
 
red-beard's Avatar
 
Join Date: Jul 2000
Location: Houston, Tejas
Posts: 43,366
Garage
Quote:
Originally Posted by DavidB911 View Post
We were always told to convert it to a number between 0 and 10. Then you can multiply the number of decimals needed. Say if its "1234" being squared it would be:

(1234)^2 = 1522756

Divide 1234 by 1000, then square 1.234. Multiply the answer by 1e6 to get 1522756.
You get serious rounding errors that way. That works in engineering, but it won't work in banking software.

A lot the answer depends on the use.
__________________
James
The pessimist complains about the wind; the optimist expects it to change; the engineer adjusts the sails.- William Arthur Ward (1921-1994)
Red-beard for President, 2020
Old 10-14-2010, 04:27 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #5 (permalink)
Registered
 
id10t's Avatar
 
Join Date: Mar 2003
Posts: 10,322
What is happening is...

A math instructor wants to offer a class based on working with number theory. Programming needed, but the math kids aren't programmers (neither is he, although he admits to some turbo pascal 25 years ago). So I hooked him up with a programming instructor who teaches basic C/C++. Match made in heaven - he gets his math stuff done, she gets projects for her students and the students get experience working with a "customer".

I get happy too, 'cause I'm building them a custom dev environment in Linux if it can't be done in VS.

The GMP library seems to work for a few tests, but I need to write a bit more code for more testing.
__________________
“IN MY EXPERIENCE, SUSAN, WITHIN THEIR HEADS TOO MANY HUMANS SPEND A LOT OF TIME IN THE MIDDLE OF WARS THAT HAPPENED CENTURIES AGO.”
Old 10-14-2010, 04:45 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #6 (permalink)
 
canna change law physics
 
red-beard's Avatar
 
Join Date: Jul 2000
Location: Houston, Tejas
Posts: 43,366
Garage
OK, then as I thought the decimal point solution (engineering notation) won't work.

You need basically and integer*128 or *256 or more.

This might be a good assignment, because it can show the students the limitations of the computer and how computers really generate numbers.

__________________
James
The pessimist complains about the wind; the optimist expects it to change; the engineer adjusts the sails.- William Arthur Ward (1921-1994)
Red-beard for President, 2020
Old 10-14-2010, 06:04 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #7 (permalink)
Reply

Thread Tools
Rate This Thread
Rate This Thread:

 


All times are GMT -8. The time now is 09:30 AM.


 
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0
Copyright 2025 Pelican Parts, LLC - Posts may be archived for display on the Pelican Parts Website -    DMCA Registered Agent Contact Page
 

DTO Garage Plus vBulletin Plugins by Drive Thru Online, Inc.