Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Problems With Large Numbers (eg. 1^10)

Author
Message
QuantumPixel
14
Years of Service
User Offline
Joined: 14th Feb 2010
Location: Alabama, USA
Posted: 26th Apr 2012 05:56
Greetings!

The program that I am working on uses very large numbers, most of which are raised to a power of ^22 or more. Yet I am having trouble getting such numbers to work correctly.

Example:


If I raise M to any power up to 10^9, it displays correctly as "1e+009." However, if I raise it to a power of 10^10 or greater, it displays as "-2.14748e+009."

This baffles me! Any insight into what causes this and how I can make it so that my program correctly represents large numbers would be of immense help.

Thanks!
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 26th Apr 2012 12:43
This is from the help menu, does it apply to your problem?


DATA TYPE RANGES

Each type of data has a maximum and minimum value known as the range. It is important to know these ranges, especially when dealing with smaller datatypes. Below is a list of datatypes and their ranges:


INTEGER Range : –2,147,483,648 to 2,147,483,647
REAL Range : 3.4E +/- 38 (7 digits)
BOOLEAN Range : 0 to 1
BYTE Range : 0 to 255
WORD Range : 0 to 65535
DWORD Range : 0 to 4,294,967,295
DOUBLE INTEGER Range : –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
DOUBLE FLOAT Range : 1.7E +/- 308 (15 digits)

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Jaeg
18
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 26th Apr 2012 15:54 Edited at: 26th Apr 2012 15:55
In some languages if you exceed the data range they'll wrap back around to their lowest value. Try using a REAL or DOUBLE.

Go ahead. Walk into Mordor.

Ball State University - Computer Science Major
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 26th Apr 2012 16:28
Hi, the wierd problem is with the use of an integer calculation: M = 1.0 * 10 ^ 10

Use a floating point calculation instead: M = 1.0 * 10.0 ^ 10.0

Or just M = 10.0 ^ 10.0



QuantumPixel
14
Years of Service
User Offline
Joined: 14th Feb 2010
Location: Alabama, USA
Posted: 26th Apr 2012 17:54
Many thanks, Chris! That fixed it!
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 28th Apr 2012 02:08
Although, unless its been fixed recently, double integers are shoddy and double floats don't work. (they work but they're just floats)

Login to post a reply

Server time is: 2024-11-23 20:33:52
Your offset time is: 2024-11-23 20:33:52