SINGLE: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
m (Removed protection from "SINGLE") |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
'''SINGLE''' variables are | '''SINGLE''' variables are 32-bits floating point numerical values up to seven digits precision ([[Wikipedia:Single-precision_floating-point_format|see IEEE 754 Single precision]]). | ||
{{PageSyntax}} | {{PageSyntax}} | ||
:: [[DIM]] ''variable'' | ; Explicit declaration | ||
: [[DIM]] {{Parameter|variable}} [[AS]] [[SINGLE]] 'AS type variant | |||
: [[DIM]] {{Parameter|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 | |||
: {{Parameter|variable}}! 'simply always use the type suffix | |||
; {{Text|'''Attention'''|red}} | |||
:* This is also the default [[Variable Types|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. | |||
{{PageDescription}} | {{PageDescription}} | ||
* Values can range up to 7 digits. Decimal point accuracy depends on whole value places taken. | * 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''). | |||
* Values | * [[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 4 | * 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 | |||
{{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}} | ||
* [[DOUBLE]], [[_FLOAT]] | * [[DOUBLE]], [[_FLOAT]] | ||
* [[LEN]] | * [[DIM]], [[DEFSNG]], [[_DEFINE]] | ||
* [[MKS$]], [[CVS]], [[_MK$]], [[_CV]] | |||
* [[LEN]], [[Constants]] | |||
* [[Variable Types]] | * [[Variable Types]] | ||
{{PageNavigation}} | {{PageNavigation}} |
Latest revision as of 14:33, 25 December 2024
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