_FLOAT

From QB64 Phoenix Edition Wiki
Revision as of 14:20, 25 December 2024 by RhoSigma (talk | contribs)
Jump to navigation Jump to search

_FLOAT variables are 80-bits floating point numerical values up to nineteen digits precision (see IEEE 754 Extended precision). This variable type is new to QB64(PE), it is not available in QuickBASIC/QBasic.


Syntax

Explicit declaration
DIM variable AS _FLOAT 'AS type variant
DIM variable## 'type suffix variant (##)
Implicit for a specific letter range
_DEFINE F-G AS _FLOAT 'all variables beginning with F(f) or G(g)
Implicit without declaration
variable## 'simply always use the type suffix
Note
  • Although the numbers are 80-bits wide (10 bytes), QB64(PE) always allocates 32 bytes to store this value.


Description

  • Values can range up to 19 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 _FLOAT.
  • Values may be given as real number (123.456) or scientific notation using F as exponent marker (1.23456F+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 32-bytes STRING values using _MK$(_FLOAT, value) and back to numbers with _CV(_FLOAT, value$).
Some useful constants are available since QB64-PE v4.0.0
  • _SIZE_OF_FLOAT = 32 'in bytes
  • _FLOAT_MIN## = -1.189731495357231765F+4932 'smallest normal number
  • _FLOAT_MAX## = 1.189731495357231765F+4932 'largest normal number
  • _FLOAT_MIN_FRAC## = 3.362103143112093506F-4932 'smallest normal number closest to zero


Availability

  • In all QB64(PE) versions there's the problem, that STR$ can't correctly handle values exceeding the DOUBLE range. This unfortunatly also affects the PRINT output.
  • Since QB64-PE v4.0.0 the _TOSTR$ function can be used, if the entire _FLOAT range must be covered. However, this doesn't fix the PRINT issue, hence you must first convert the number and then print the string instead.


See also



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