Real
Data Type
Holds signed floating-point values that must be a minimum of 64 bits (8 bytes) and gives good performance. On Intel platforms this could be an 80-bit (10-byte) value in the range −1.18973149535723176502E+4932 to −3.64519953188247460253E−4951 for negative values and 3.64519953188247460253E−4951 to 1.18973149535723176502E+4932 for positive values.
Instructions
- Precision
- Floating-point data types cannot store all values accurately. Operations, for example, when values are compared, can cause results that you think are incorrect. See Data Type Troubleshooting for more information.
- Performance
- ViviFire makes sure that when you calculate with
Real
, they are the fastest for a type at minimum as large asReal64
. Platforms for which the fastest floating-point type is smaller thanReal64
must useReal64
to be compatible. - Default value
- When you declare a variable of type
Real
and do not initialize it, its default value is zero (0.0). - Automatic conversions
Real
widens toReal128
without risk of overflow.- Zeros at the end
- The floating-point data types usually cannot show 0 characters at the end, after the decimal point. Thus numbers, for example, 1.4200 and 1.42 are the same value. If you must show zeros at the end, you must use a formatter procedure.
- Type characters
- If you add an exclamation point (
!
) to the end of a variable name, it has the typeReal
.
Real literal
[ integer_part ] . fractional_part [ E [ + | - ] exponent_part ] [ ! ]
or
integer_part E [ + | - ] exponent_part [ ! ]
or
integer_part !
Parts
integer_part
- One or more decimal digits.
You can use an underscore character (
_
) to divide it into groups of digits. fractional_part
- One or more decimal digits.
exponent_part
- One or more decimal digits. Typically the maximum number of digits is three or four.
Shared methods and properties
Real.Default As Real
- Returns the default value,
0.0
. Real.Epsilon As Real
- Returns the smallest difference between two values.
Real.IsInf(num As Real) As Boolean
- Returns true if
num
is infinity (positive or negative). Mathematical overflow is one cause of this result. Real.IsNaN(num As Real) As Boolean
- Returns true if
num
is not a number (Nan). “Zero divided by zero” and “square root of a negative” are two causes of this result. Real.IsNegInf(num As Real) As Boolean
- Returns true if
num
is negative infinity. Real.IsPosInf(num As Real) As Boolean
- Returns true if
num
is positive infinity. Real.Max As Real
- Returns the maximum positive value.
Real.Min As Real
- Returns the minimum negative value.
Real.Parse(str As String, Optional #format As Format) As Real
- Tries to parse a string that shows as a floating-point number.
- If
#format
is not given or is#Null
, it uses the format of the local culture. Or you can make it clear withFormat.UserLocale
. - If
#format
isFormat.RealLiteral
, it uses the format of a literal of typeReal
. Real.Size As Int
- Returns the number of available bytes. Typical values are 8 or 10.
Examples
Dim foo As Real
Dim bar!