Floating-point variables - standard rep?

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
chrisn
Newbie
Posts:3
Joined:Fri Oct 24, 2003 8:07 pm
Floating-point variables - standard rep?

Post by chrisn » Thu Nov 20, 2003 3:20 pm

Could someone please tell me whether or not QB represents floating-point variables according to the IEEE standard?

E.g. the single-precision standard (32 bit) says that values are represented as:

S / EEEEEEEE / FFFFFFFFFFFFFFFFFFFFFFF

and the lowest representable numbers have absolute value equal to 2^(-23) * 2^(-126) = 2^(-149) = 1.4012984643248170709237295832899 * 10^(-45)

I think QB probably does conform to the standard, since it accepts a single-precision value of 2^(-149) but reads 2^(-150) as 0.

However, the helpfile, under QBasic Environment Limits / Name, String, and Number Limits, says the  lowest representable numbers (single-precision) have absolute value equal to  2.802597 * 10*(-45), which is
2^(-148 ), rather than 2^(-149).

I'd be grateful if this could be nailed down definitively, e.g. that QB either does or does not use the IEEE standards for representing numerical variables of all four types (INTEGER, LONG, SINGLE, DOUBLE).

The standards are described at:

http://www.psc.edu/general/software/pac ... /ieee.html

Many thanks! :)

Chris

Guest

Re: Floating-point variables - standard rep?

Post by Guest » Tue Nov 09, 2004 6:17 am

chrisn wrote:Could someone please tell me whether or not QB represents floating-point variables according to the IEEE standard?

E.g. the single-precision standard (32 bit) says that values are represented as:

S / EEEEEEEE / FFFFFFFFFFFFFFFFFFFFFFF

and the lowest representable numbers have absolute value equal to 2^(-23) * 2^(-126) = 2^(-149) = 1.4012984643248170709237295832899 * 10^(-45)

I think QB probably does conform to the standard, since it accepts a single-precision value of 2^(-149) but reads 2^(-150) as 0.

However, the helpfile, under QBasic Environment Limits / Name, String, and Number Limits, says the  lowest representable numbers (single-precision) have absolute value equal to  2.802597 * 10*(-45), which is
2^(-148 ), rather than 2^(-149).

I'd be grateful if this could be nailed down definitively, e.g. that QB either does or does not use the IEEE standards for representing numerical variables of all four types (INTEGER, LONG, SINGLE, DOUBLE).

The standards are described at:

http://www.psc.edu/general/software/pac ... /ieee.html

Many thanks! :)

Chris
It's been almost a year since you posted, but I just joined this forum, and saw your old post.

While I do not claim of having knowledge of the numerical basis for any of the BASIC-based languages, I do recall that a bit is reserved for the sign. This, possibly, would explain the 2^-148 "smallest" number, rather than the IEEE 2^-149. Does this make sense to you?

Ralph
QBasic God
Posts:134
Joined:Sat Nov 06, 2004 2:27 am
Location:Katy, Texas

QuickBASIC and IEEE

Post by Ralph » Tue Nov 09, 2004 6:20 am

Sorry about that "Guest" post. I hadn't logged in, and didn't notice, until after I posted! :oops:

Ralph
Ralph. Running QuickBASIC Version 4.5, Windows XP Home Edition, Version 2002, Service Pack 2, and HP LaserJet 4L printer.

Post Reply