Page 1 of 1

Floating-point variables - standard rep?

Posted: Thu Nov 20, 2003 3:20 pm
by chrisn
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

Re: Floating-point variables - standard rep?

Posted: Tue Nov 09, 2004 6:17 am
by Guest
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?

QuickBASIC and IEEE

Posted: Tue Nov 09, 2004 6:20 am
by Ralph
Sorry about that "Guest" post. I hadn't logged in, and didn't notice, until after I posted! :oops:

Ralph