What's the largest possible double number?

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
User avatar
Mentat
Veteran
Posts: 409
Joined: Tue Aug 07, 2007 3:39 pm
Location: NC, US

What's the largest possible double number?

Post by Mentat » Sun Dec 02, 2007 5:54 pm

Please don't use e.
For any grievances posted above, I blame whoever is in charge . . .

Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Re: What's the largest possible double number?

Post by Mac » Sun Dec 02, 2007 8:33 pm

Mentat wrote:Please don't use e.
How about "d"?

K# DOUBLE
double-precision 64-bit floating-point
Sixteen place accuracy, Max = 1.797693134862315D+308

User avatar
Mentat
Veteran
Posts: 409
Joined: Tue Aug 07, 2007 3:39 pm
Location: NC, US

Re: What's the largest possible double number?

Post by Mentat » Sun Dec 02, 2007 8:56 pm

Mac wrote:
Mentat wrote:Please don't use e.
How about "d"?

K# DOUBLE
double-precision 64-bit floating-point
Sixteen place accuracy, Max = 1.797693134862315D+308
But what does the e+308 mean? I don't want precision, I just want a max number.
For any grievances posted above, I blame whoever is in charge . . .

BDZ
Coder
Posts: 49
Joined: Sun Nov 20, 2005 5:41 pm
Location: Wisconsin
Contact:

Re: What's the largest possible double number?

Post by BDZ » Sun Dec 02, 2007 9:14 pm

Mentat wrote: But what does the e+308 mean? I don't want precision, I just want a max number.
"d+308" means "times 10 raised to the 308th power."

User avatar
Mentat
Veteran
Posts: 409
Joined: Tue Aug 07, 2007 3:39 pm
Location: NC, US

Post by Mentat » Sun Dec 02, 2007 9:20 pm

Oh. Well, could a number such as 400 and 6 be Double without truncating or any other problems? I'm asking this becuase I'm having a very wierd bug. It's as if the numbers are being "squashed" as soon as they're declared, and I'm using Doubles. Either that, or being "exploded."
For any grievances posted above, I blame whoever is in charge . . .

Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Re: What's the largest possible double number?

Post by Mac » Sun Dec 02, 2007 9:30 pm

BDZ wrote:
Mentat wrote:"d+308" means "times 10 raised to the 308th power."
Right. The letter "d" is used to designate you need double precision to hold this number. It otherwise the same as "e", meaning "exponent".

To directly answer your question: 179769313486231500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Does that help you out?

The problem with representing the number that way is that it implies that more accuracy is known than is.

Example:

1.24e4 means more than 1.24 * 10^4 which is 12400.

It means "A number between 12350 and 12450.

And in Physics is used a lot to indicate the accuracy known.

But in computing, it has lost the accuracy connotion, but instead simply means how the number is stored.

1.24e4 is stored as something like (4)(1240....0) where .... is the amount of significance that can be stored.

Mac

User avatar
Mentat
Veteran
Posts: 409
Joined: Tue Aug 07, 2007 3:39 pm
Location: NC, US

Post by Mentat » Sun Dec 02, 2007 9:37 pm

Yes, but could it be a bug for numbers such as 12 and 368? I'm getting ridiculus numbers such as 1.788...E-307 . All of them. Just after I initalize them to equal numbers like 540.
For any grievances posted above, I blame whoever is in charge . . .

User avatar
burger2227
Veteran
Posts: 2396
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Mon Dec 03, 2007 3:28 am

Mac is trying to tell you that some numbers such as 120 / 1500 will be
represented as an exponent of the number in some cases. This is called
scientific notation for an infinite or very long number, which no Qbasic
program can do.

To print the number to the screen in real terms, use PRINT USING and
only use the digits that you need for accuracy. Really long decimal place
numbers are really kind of stupid to use as they can be rounded off
simply!

PRINT USING " ######.##########", 120/1500

It will not change the real number and can be used in any calculation you need.
Use some kind of rounding method to change the actual number.
Once you get the number from PRINT USING, you can then round it off
with multiplication and division to the accuracy you need in a program.

When a double number is used in a calculation, it will tend to do that when
the actual value is between two values. I made a program once that
would change 11 to 11.001 somehow. Double is kinda funky!

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

cha0s
Newbie
Posts: 7
Joined: Tue Mar 14, 2006 12:41 am
Location: IL, USA
Contact:

Post by cha0s » Sun Dec 09, 2007 1:01 pm

Just like to point out, this isn't necessarily a QB error, it's just because doubles don't have infinite space to store the number, so it has to approximate. This is one of the first concepts you need to learn to do "real" programming. Don't ever compare two floating point numbers, do like (abs(num1 - num2) < .0001), or some other suitable range.

Post Reply