struct Float32
inherits Float
¶
Constants¶
DIGITS = 6
¶
6
The number of decimal digits that can be represented without losing precision
EPSILON = 1.19209290e-07_f32
¶
1.19209290e-07_f32
The machine epsilon (difference between 1.0 and the next representable value)
INFINITY = (1_f32 / 0_f32).as(Float32)
¶
(1_f32 / 0_f32).as(Float32)
MANT_DIGITS = 24
¶
24
The number of digits that can be represented without losing precision (in base RADIX)
MAX = 3.40282347e+38_f32
¶
3.40282347e+38_f32
Largest finite value
MAX_10_EXP = 38
¶
38
The maximum possible power of 10 exponent (such that 10**MAX_10_EXP is representable)
MAX_EXP = 128
¶
128
The maximum possible normal power of 2 exponent
MIN = -3.40282347e+38_f32
¶
-3.40282347e+38_f32
Smallest finite value
MIN_10_EXP = -37
¶
-37
The minimum possible power of 10 exponent (such that 10**MIN_10_EXP is representable)
MIN_EXP = -125
¶
-125
The minimum possible normal power of 2 exponent
MIN_POSITIVE = 1.17549435e-38_f32
¶
1.17549435e-38_f32
Smallest representable positive value
NAN = (0_f32 / 0_f32).as(Float32)
¶
(0_f32 / 0_f32).as(Float32)
RADIX = 2
¶
2
The radix or integer base used by the internal representation
Class methods¶
Methods¶
#round_away
¶
Rounds towards the nearest integer. If both neighboring integers are equidistant, rounds away from zero.
#round_even : self
¶
: self
Rounds towards the nearest integer. If both neighboring integers are equidistant, rounds towards the even neighbor (Banker's rounding).
#to_f : Float64
¶
: Float64
Returns self
converted to Float64
.
Raises OverflowError
in case of overflow.
#to_f! : Float64
¶
: Float64
Returns self
converted to Float64
.
In case of overflow a wrapping is performed.
#to_f32 : Float32
¶
: Float32
Returns self
converted to Float32
.
Raises OverflowError
in case of overflow.
#to_f32! : Float32
¶
: Float32
Returns self
converted to Float32
.
In case of overflow a wrapping is performed.
#to_f64 : Float64
¶
: Float64
Returns self
converted to Float64
.
Raises OverflowError
in case of overflow.
#to_f64! : Float64
¶
: Float64
Returns self
converted to Float64
.
In case of overflow a wrapping is performed.
#to_i : Int32
¶
: Int32
Returns self
converted to Int32
.
Raises OverflowError
in case of overflow.
#to_i! : Int32
¶
: Int32
Returns self
converted to Int32
.
In case of overflow a wrapping is performed.
#to_i128 : Int128
¶
: Int128
Returns self
converted to Int128
.
Raises OverflowError
in case of overflow.
#to_i128! : Int128
¶
: Int128
Returns self
converted to Int128
.
In case of overflow a wrapping is performed.
#to_i16 : Int16
¶
: Int16
Returns self
converted to Int16
.
Raises OverflowError
in case of overflow.
#to_i16! : Int16
¶
: Int16
Returns self
converted to Int16
.
In case of overflow a wrapping is performed.
#to_i32 : Int32
¶
: Int32
Returns self
converted to Int32
.
Raises OverflowError
in case of overflow.
#to_i32! : Int32
¶
: Int32
Returns self
converted to Int32
.
In case of overflow a wrapping is performed.
#to_i64 : Int64
¶
: Int64
Returns self
converted to Int64
.
Raises OverflowError
in case of overflow.
#to_i64! : Int64
¶
: Int64
Returns self
converted to Int64
.
In case of overflow a wrapping is performed.
#to_i8 : Int8
¶
: Int8
Returns self
converted to Int8
.
Raises OverflowError
in case of overflow.
#to_i8! : Int8
¶
: Int8
Returns self
converted to Int8
.
In case of overflow a wrapping is performed.
#to_s : String
¶
: String
Returns a string representation of this object.
Descendants must usually not override this method. Instead,
they must override to_s(io)
, which must append to the given
IO object.
#to_s(io : IO) : Nil
¶
(io : IO) : Nil
Appends a String
representation of this object
to the given IO
object.
An object must never append itself to the io argument,
as this will in turn call to_s(io)
on it.
#to_u : UInt32
¶
: UInt32
Returns self
converted to UInt32
.
Raises OverflowError
in case of overflow.
#to_u! : UInt32
¶
: UInt32
Returns self
converted to UInt32
.
In case of overflow a wrapping is performed.
#to_u128 : UInt128
¶
: UInt128
Returns self
converted to UInt128
.
Raises OverflowError
in case of overflow.
#to_u128! : UInt128
¶
: UInt128
Returns self
converted to UInt128
.
In case of overflow a wrapping is performed.
#to_u16 : UInt16
¶
: UInt16
Returns self
converted to UInt16
.
Raises OverflowError
in case of overflow.
#to_u16! : UInt16
¶
: UInt16
Returns self
converted to UInt16
.
In case of overflow a wrapping is performed.
#to_u32 : UInt32
¶
: UInt32
Returns self
converted to UInt32
.
Raises OverflowError
in case of overflow.
#to_u32! : UInt32
¶
: UInt32
Returns self
converted to UInt32
.
In case of overflow a wrapping is performed.
#to_u64 : UInt64
¶
: UInt64
Returns self
converted to UInt64
.
Raises OverflowError
in case of overflow.
#to_u64! : UInt64
¶
: UInt64
Returns self
converted to UInt64
.
In case of overflow a wrapping is performed.
#to_u8 : UInt8
¶
: UInt8
Returns self
converted to UInt8
.
Raises OverflowError
in case of overflow.
#to_u8! : UInt8
¶
: UInt8
Returns self
converted to UInt8
.
In case of overflow a wrapping is performed.