DOUBLE: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 1: Line 1:
[[DOUBLE]] type floating point numerical values use 8 bytes per value.
'''DOUBLE''' variables are 64-bits floating point numerical values up to sixteen digits precision ([[Wikipedia:Double-precision_floating-point_format|see IEEE 754 Double precision]]).




{{PageSyntax}}
{{PageSyntax}}
: [[DIM]] {{Parameter|variable}} [[AS]] [[DOUBLE]]
; Explicit declaration
: [[DIM]] {{Parameter|variable}} [[AS]] [[DOUBLE]] 'AS type variant
: [[DIM]] {{Parameter|variable}}# 'type suffix variant ('''#''')
; Implicit for a specific letter range
: [[DEFDBL]] D-E '(legacy variant) all variables beginning with D(d) or E(e)
: [[_DEFINE]] D-E [[AS]] [[DOUBLE]] 'new variant in QB64(PE)
; Implicit without declaration
: {{Parameter|variable}}# 'simply always use the type suffix




{{PageDescription}}
{{PageDescription}}
* Literal or variable values can range up to 15 decimal point places.
* Values can range up to 16 digits. Decimal point accuracy depends on whole value places taken.
* The variable suffix type is '''#'''.
* The suffix '''#''' can also be placed after a literal numerical value to designate the value as '''DOUBLE'''.
* Use DOUBLE and [[_FLOAT]] variables sparingly as they use a lot of program memory.
* Values may be given as real number (''123.456'') or [[scientific notation]] using '''D''' as exponent marker (''1.23456D+2'').
* Values returned may be expressed using exponential or [[scientific notation]] using '''E''' for SINGLE or '''D''' for DOUBLE precision.
* [[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]].
* Floating decimal point numerical values cannot be [[_UNSIGNED]].
* Values can be converted to 8 byte [[ASCII]] string values using [[_MKD$]] and back with [[_CVD]].
* Values can be converted to 8-bytes [[STRING]] values using [[_MKD$]] and back to numbers with [[_CVD]].
* '''When a variable has not been defined or has no type suffix, the value defaults to [[SINGLE]].'''
; Some useful [[constants]] are available since QB64-PE v4.0.0
* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.'''
:* _SIZE_OF_DOUBLE = 8 'in bytes
:* _DOUBLE_MIN# = -1.797693134862315D+308 'smallest normal number
:* _DOUBLE_MAX# = 1.797693134862315D+308 'largest normal number
:* _DOUBLE_MIN_FRAC# = 2.225073858507201D-308 'smallest normal number closest to zero


=== QBasic/QuickBASIC ===
 
* Results of mathematical calculations may be approximate or slow in QuickBASIC 4.5.
{{PageAvailability}}
<!-- QB64 = a version or none, QBPE = a version or all, Platforms = yes or no -->
<gallery widths="48px" heights="48px" mode="nolines">
File:Qb64.png|'''all'''
File:Qbpe.png|'''all'''
File:Apix.png
File:Win.png|'''yes'''
File:Lnx.png|'''yes'''
File:Osx.png|'''yes'''
</gallery>
<!-- additional availability notes go below here -->




{{PageSeeAlso}}
{{PageSeeAlso}}
* [[DIM]], [[DEFDBL]]
* [[MKD$]], [[CVD]]
* [[SINGLE]], [[_FLOAT]]
* [[SINGLE]], [[_FLOAT]]
* [[LEN]]
* [[DIM]], [[DEFDBL]], [[_DEFINE]]
* [[MKD$]], [[CVD]], [[_MK$]], [[_CV]]
* [[LEN]], [[Constants]]
* [[Variable Types]]
* [[Variable Types]]




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 14:20, 25 December 2024

DOUBLE variables are 64-bits floating point numerical values up to sixteen digits precision (see IEEE 754 Double precision).


Syntax

Explicit declaration
DIM variable AS DOUBLE 'AS type variant
DIM variable# 'type suffix variant (#)
Implicit for a specific letter range
DEFDBL D-E '(legacy variant) all variables beginning with D(d) or E(e)
_DEFINE D-E AS DOUBLE 'new variant in QB64(PE)
Implicit without declaration
variable# 'simply always use the type suffix


Description

  • Values can range up to 16 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 DOUBLE.
  • Values may be given as real number (123.456) or scientific notation using D as exponent marker (1.23456D+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 8-bytes STRING values using _MKD$ and back to numbers with _CVD.
Some useful constants are available since QB64-PE v4.0.0
  • _SIZE_OF_DOUBLE = 8 'in bytes
  • _DOUBLE_MIN# = -1.797693134862315D+308 'smallest normal number
  • _DOUBLE_MAX# = 1.797693134862315D+308 'largest normal number
  • _DOUBLE_MIN_FRAC# = 2.225073858507201D-308 '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