Julia
provides special floating point values to represent Positive infinity, Negative
infinity, not a number values.
Special Value
|
Description
|
Inf16
|
Represents
positive infinity, specific to Float16 type
|
-Inf16
|
Represents
negative infinity, specific to Float16 type
|
Inf32
|
Represents
positive infinity, specific to Float32 type
|
-Inf32
|
Represents
negative infinity, specific to Float32 type
|
Inf
|
Represents
positive infinity, specific to Float64 type
|
-Inf
|
Represents
negative infinity, specific to Float64 type
|
Nan16
|
Represent
not a number, specific to Float16 type.
|
Nan32
|
Represent
not a number, specific to Float32 type.
|
Nan
|
Represent
not a number, specific to Float64 type.
|
Note:
Nan is not
equal to any floating-point number, including Nan itself.
julia> 10/0 Inf julia> -10/0 -Inf julia> 23.43/Inf 0.0 julia> 23.43/-Inf -0.0 julia> Inf/-Inf NaN julia> -Inf/Inf NaN julia> Inf16/Inf32 NaN32 julia> Inf16/Inf64 NaN julia> Inf64/Inf16 NaN julia> 1/Inf 0.0 julia> Inf*Inf Inf julia> Inf-Inf NaN julia> Inf+Inf Inf julia> Inf/Inf NaN
You can use
typemin(), typemax() functions to get minimum and maximum values for given
type.
julia> (typemin(Float16),typemax(Float16)) (-Inf16,Inf16) julia> (typemin(Float32),typemax(Float32)) (-Inf32,Inf32) julia> (typemin(Float64),typemax(Float64)) (-Inf,Inf)
No comments:
Post a Comment