SINGLE

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search

SINGLE variables are 32-bits floating point numerical values up to seven digits precision (see IEEE 754 Single precision).


Syntax

Explicit declaration
DIM variable AS SINGLE 'AS type variant
DIM variable! 'type suffix variant (no suffix or !)
Implicit for a specific letter range
DEFSNG S-T '(legacy variant) all variables beginning with S(s) or T(t)
_DEFINE S-T AS SINGLE 'new variant in QB64(PE)
Implicit without declaration
variable! 'simply always use the type suffix
Attention
  • This is also the default variable type in QuickBASIC/QBasic and QB64(PE). All variables not explicitly declared, defined in a letter range or designated with a type suffix automatically become a SINGLE number.


Description

  • Values can range up to 7 digits. Decimal point accuracy depends on whole value places taken.
  • The suffix ! can also be placed after a literal numerical value to designate the value as SINGLE.
  • Values may be given as real number (123.456) or scientific notation using E as exponent marker (1.23456E+2).
  • PRINT usually takes the shorter of both notations (depending on the value) to output the numbers. In alternative you may use PRINT USING to designate your desired output format.
  • Floating decimal point numerical values cannot be _UNSIGNED.
  • Values can be converted to 4-bytes STRING values using _MKS$ and back to numbers with _CVS.
Some useful constants are available since QB64-PE v4.0.0
  • _SIZE_OF_SINGLE = 4 'in bytes
  • _SINGLE_MIN! = -3.402823E+38 'smallest normal number
  • _SINGLE_MAX! = 3.402823E+38 'largest normal number
  • _SINGLE_MIN_FRAC! = 1.175494E-38 'smallest normal number closest to zero


Availability


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link