struct Float16
- Float16
- Float
- Number
- Value
- Object
Overview
Float16 (also called half in other languages) is an implementation of the IEEE 754 half-precision binary floating-point format
This implementation is ported from https://github.com/mm2/Little-CMS/blob/c6d1c9c07cfd03642d154973d036fccc59a2075c/src/cmshalf.c
Defined in:
float16cr.crConstant Summary
-
VERSION =
"0.1.0"
Constructors
-
.new(value : String, whitespace : Bool = true, strict : Bool = true) : self
Returns a
Float16by invokingString#to_f32#to_f16on value. - .new(value : Float32)
- .new(value) : self
-
.new!(value) : self
Returns a
Float16by invokingto_f16!on value.
Instance Method Summary
-
#!=(other : Int8) : Bool
Returns
trueifselfis not equal to other. -
#!=(other : Int16) : Bool
Returns
trueifselfis not equal to other. -
#!=(other : Int32) : Bool
Returns
trueifselfis not equal to other. -
#!=(other : Int64) : Bool
Returns
trueifselfis not equal to other. -
#!=(other : Int128) : Bool
Returns
trueifselfis not equal to other. -
#!=(other : UInt8) : Bool
Returns
trueifselfis not equal to other. -
#!=(other : UInt16) : Bool
Returns
trueifselfis not equal to other. -
#!=(other : UInt32) : Bool
Returns
trueifselfis not equal to other. -
#!=(other : UInt64) : Bool
Returns
trueifselfis not equal to other. -
#!=(other : UInt128) : Bool
Returns
trueifselfis not equal to other. -
#!=(other : Float16) : Bool
Returns
trueifselfis not equal to other. -
#!=(other : Float32) : Bool
Returns
trueifselfis not equal to other. -
#!=(other : Float64) : Bool
Returns
trueifselfis not equal to other. -
#*(other : Int8) : Float16
Returns the result of multiplying
selfand other. -
#*(other : Int16) : Float16
Returns the result of multiplying
selfand other. -
#*(other : Int32) : Float16
Returns the result of multiplying
selfand other. -
#*(other : Int64) : Float16
Returns the result of multiplying
selfand other. -
#*(other : Int128) : Float16
Returns the result of multiplying
selfand other. -
#*(other : UInt8) : Float16
Returns the result of multiplying
selfand other. -
#*(other : UInt16) : Float16
Returns the result of multiplying
selfand other. -
#*(other : UInt32) : Float16
Returns the result of multiplying
selfand other. -
#*(other : UInt64) : Float16
Returns the result of multiplying
selfand other. -
#*(other : UInt128) : Float16
Returns the result of multiplying
selfand other. -
#*(other : Float16) : Float16
Returns the result of multiplying
selfand other. -
#*(other : Float32) : Float16
Returns the result of multiplying
selfand other. -
#*(other : Float64) : Float16
Returns the result of multiplying
selfand other. - #**(other : Int32) : Float16
-
#+(other : Int8) : Float16
Returns the result of adding
selfand other. -
#+(other : Int16) : Float16
Returns the result of adding
selfand other. -
#+(other : Int32) : Float16
Returns the result of adding
selfand other. -
#+(other : Int64) : Float16
Returns the result of adding
selfand other. -
#+(other : Int128) : Float16
Returns the result of adding
selfand other. -
#+(other : UInt8) : Float16
Returns the result of adding
selfand other. -
#+(other : UInt16) : Float16
Returns the result of adding
selfand other. -
#+(other : UInt32) : Float16
Returns the result of adding
selfand other. -
#+(other : UInt64) : Float16
Returns the result of adding
selfand other. -
#+(other : UInt128) : Float16
Returns the result of adding
selfand other. -
#+(other : Float16) : Float16
Returns the result of adding
selfand other. -
#+(other : Float32) : Float16
Returns the result of adding
selfand other. -
#+(other : Float64) : Float16
Returns the result of adding
selfand other. -
#-(other : Int8) : Float16
Returns the result of subtracting
selfand other. -
#-(other : Int16) : Float16
Returns the result of subtracting
selfand other. -
#-(other : Int32) : Float16
Returns the result of subtracting
selfand other. -
#-(other : Int64) : Float16
Returns the result of subtracting
selfand other. -
#-(other : Int128) : Float16
Returns the result of subtracting
selfand other. -
#-(other : UInt8) : Float16
Returns the result of subtracting
selfand other. -
#-(other : UInt16) : Float16
Returns the result of subtracting
selfand other. -
#-(other : UInt32) : Float16
Returns the result of subtracting
selfand other. -
#-(other : UInt64) : Float16
Returns the result of subtracting
selfand other. -
#-(other : UInt128) : Float16
Returns the result of subtracting
selfand other. -
#-(other : Float16) : Float16
Returns the result of subtracting
selfand other. -
#-(other : Float32) : Float16
Returns the result of subtracting
selfand other. -
#-(other : Float64) : Float16
Returns the result of subtracting
selfand other. - #/(other : Int8) : Float16
- #/(other : UInt8) : Float16
- #/(other : Int16) : Float16
- #/(other : UInt16) : Float16
- #/(other : Int32) : Float16
- #/(other : UInt32) : Float16
- #/(other : Int64) : Float16
- #/(other : UInt64) : Float16
- #/(other : Int128) : Float16
- #/(other : UInt128) : Float16
- #/(other : Float64) : Float64
- #/(other : Float32) : Float32
-
#/(other : Float16) : Float16
Returns the result of division
selfand other. - #/(other : BigInt) : BigFloat
- #/(other : BigFloat) : BigFloat
- #/(other : BigDecimal) : BigDecimal
- #/(other : BigRational) : BigRational
-
#<(other : Int8) : Bool
Returns
trueifselfis less than other. -
#<(other : Int16) : Bool
Returns
trueifselfis less than other. -
#<(other : Int32) : Bool
Returns
trueifselfis less than other. -
#<(other : Int64) : Bool
Returns
trueifselfis less than other. -
#<(other : Int128) : Bool
Returns
trueifselfis less than other. -
#<(other : UInt8) : Bool
Returns
trueifselfis less than other. -
#<(other : UInt16) : Bool
Returns
trueifselfis less than other. -
#<(other : UInt32) : Bool
Returns
trueifselfis less than other. -
#<(other : UInt64) : Bool
Returns
trueifselfis less than other. -
#<(other : UInt128) : Bool
Returns
trueifselfis less than other. -
#<(other : Float16) : Bool
Returns
trueifselfis less than other. -
#<(other : Float32) : Bool
Returns
trueifselfis less than other. -
#<(other : Float64) : Bool
Returns
trueifselfis less than other. -
#<=(other : Int8) : Bool
Returns
trueifselfis less than or equal to other. -
#<=(other : Int16) : Bool
Returns
trueifselfis less than or equal to other. -
#<=(other : Int32) : Bool
Returns
trueifselfis less than or equal to other. -
#<=(other : Int64) : Bool
Returns
trueifselfis less than or equal to other. -
#<=(other : Int128) : Bool
Returns
trueifselfis less than or equal to other. -
#<=(other : UInt8) : Bool
Returns
trueifselfis less than or equal to other. -
#<=(other : UInt16) : Bool
Returns
trueifselfis less than or equal to other. -
#<=(other : UInt32) : Bool
Returns
trueifselfis less than or equal to other. -
#<=(other : UInt64) : Bool
Returns
trueifselfis less than or equal to other. -
#<=(other : UInt128) : Bool
Returns
trueifselfis less than or equal to other. -
#<=(other : Float16) : Bool
Returns
trueifselfis less than or equal to other. -
#<=(other : Float32) : Bool
Returns
trueifselfis less than or equal to other. -
#<=(other : Float64) : Bool
Returns
trueifselfis less than or equal to other. -
#==(other : Int8) : Bool
Returns
trueifselfis equal to other. -
#==(other : Int16) : Bool
Returns
trueifselfis equal to other. -
#==(other : Int32) : Bool
Returns
trueifselfis equal to other. -
#==(other : Int64) : Bool
Returns
trueifselfis equal to other. -
#==(other : Int128) : Bool
Returns
trueifselfis equal to other. -
#==(other : UInt8) : Bool
Returns
trueifselfis equal to other. -
#==(other : UInt16) : Bool
Returns
trueifselfis equal to other. -
#==(other : UInt32) : Bool
Returns
trueifselfis equal to other. -
#==(other : UInt64) : Bool
Returns
trueifselfis equal to other. -
#==(other : UInt128) : Bool
Returns
trueifselfis equal to other. -
#==(other : Float16) : Bool
Returns
trueifselfis equal to other. -
#==(other : Float32) : Bool
Returns
trueifselfis equal to other. -
#==(other : Float64) : Bool
Returns
trueifselfis equal to other. -
#>(other : Int8) : Bool
Returns
trueifselfis greater than other. -
#>(other : Int16) : Bool
Returns
trueifselfis greater than other. -
#>(other : Int32) : Bool
Returns
trueifselfis greater than other. -
#>(other : Int64) : Bool
Returns
trueifselfis greater than other. -
#>(other : Int128) : Bool
Returns
trueifselfis greater than other. -
#>(other : UInt8) : Bool
Returns
trueifselfis greater than other. -
#>(other : UInt16) : Bool
Returns
trueifselfis greater than other. -
#>(other : UInt32) : Bool
Returns
trueifselfis greater than other. -
#>(other : UInt64) : Bool
Returns
trueifselfis greater than other. -
#>(other : UInt128) : Bool
Returns
trueifselfis greater than other. -
#>(other : Float16) : Bool
Returns
trueifselfis greater than other. -
#>(other : Float32) : Bool
Returns
trueifselfis greater than other. -
#>(other : Float64) : Bool
Returns
trueifselfis greater than other. -
#>=(other : Int8) : Bool
Returns
trueifselfis greater than or equal to other. -
#>=(other : Int16) : Bool
Returns
trueifselfis greater than or equal to other. -
#>=(other : Int32) : Bool
Returns
trueifselfis greater than or equal to other. -
#>=(other : Int64) : Bool
Returns
trueifselfis greater than or equal to other. -
#>=(other : Int128) : Bool
Returns
trueifselfis greater than or equal to other. -
#>=(other : UInt8) : Bool
Returns
trueifselfis greater than or equal to other. -
#>=(other : UInt16) : Bool
Returns
trueifselfis greater than or equal to other. -
#>=(other : UInt32) : Bool
Returns
trueifselfis greater than or equal to other. -
#>=(other : UInt64) : Bool
Returns
trueifselfis greater than or equal to other. -
#>=(other : UInt128) : Bool
Returns
trueifselfis greater than or equal to other. -
#>=(other : Float16) : Bool
Returns
trueifselfis greater than or equal to other. -
#>=(other : Float32) : Bool
Returns
trueifselfis greater than or equal to other. -
#>=(other : Float64) : Bool
Returns
trueifselfis greater than or equal to other. - #ceil : Float16
- #clone
-
#fdiv(other : Int8) : Float16
Returns the float division of
selfand other. -
#fdiv(other : Int16) : Float16
Returns the float division of
selfand other. -
#fdiv(other : Int32) : Float16
Returns the float division of
selfand other. -
#fdiv(other : Int64) : Float16
Returns the float division of
selfand other. -
#fdiv(other : Int128) : Float16
Returns the float division of
selfand other. -
#fdiv(other : UInt8) : Float16
Returns the float division of
selfand other. -
#fdiv(other : UInt16) : Float16
Returns the float division of
selfand other. -
#fdiv(other : UInt32) : Float16
Returns the float division of
selfand other. -
#fdiv(other : UInt64) : Float16
Returns the float division of
selfand other. -
#fdiv(other : UInt128) : Float16
Returns the float division of
selfand other. -
#fdiv(other : Float16) : Float16
Returns the float division of
selfand other. -
#fdiv(other : Float32) : Float16
Returns the float division of
selfand other. -
#fdiv(other : Float64) : Float16
Returns the float division of
selfand other. - #floor : Float16
-
#round_away : Float16
Rounds towards the nearest integer.
-
#round_even : Float16
Rounds towards the nearest integer.
-
#to_f : Float64
Returns
selfconverted toFloat64. -
#to_f! : Float64
Returns
selfconverted toFloat64. - #to_f32 : Float32
-
#to_f64 : Float64
Returns
selfconverted toFloat64. -
#to_f64! : Float64
Returns
selfconverted toFloat64. -
#to_i : Int32
Returns
selfconverted toInt32. -
#to_i! : Int32
Returns
selfconverted toInt32. -
#to_i128 : Int128
Returns
selfconverted toInt128. -
#to_i128! : Int128
Returns
selfconverted toInt128. -
#to_i16 : Int16
Returns
selfconverted toInt16. -
#to_i16! : Int16
Returns
selfconverted toInt16. -
#to_i32 : Int32
Returns
selfconverted toInt32. -
#to_i32! : Int32
Returns
selfconverted toInt32. -
#to_i64 : Int64
Returns
selfconverted toInt64. -
#to_i64! : Int64
Returns
selfconverted toInt64. -
#to_i8 : Int8
Returns
selfconverted toInt8. -
#to_i8! : Int8
Returns
selfconverted toInt8. -
#to_s(io : IO) : Nil
Prints a nicely readable and concise string representation of this object, typically intended for users, to io.
-
#to_s : String
Returns a nicely readable and concise string representation of this object, typically intended for users.
-
#to_u : UInt32
Returns
selfconverted toUInt32. -
#to_u! : UInt32
Returns
selfconverted toUInt32. -
#to_u128 : UInt128
Returns
selfconverted toUInt128. -
#to_u128! : UInt128
Returns
selfconverted toUInt128. -
#to_u16 : UInt16
Returns
selfconverted toUInt16. -
#to_u16! : UInt16
Returns
selfconverted toUInt16. -
#to_u32 : UInt32
Returns
selfconverted toUInt32. -
#to_u32! : UInt32
Returns
selfconverted toUInt32. -
#to_u64 : UInt64
Returns
selfconverted toUInt64. -
#to_u64! : UInt64
Returns
selfconverted toUInt64. -
#to_u8 : UInt8
Returns
selfconverted toUInt8. -
#to_u8! : UInt8
Returns
selfconverted toUInt8. - #trunc : Float16
Constructor Detail
Returns a Float16 by invoking String#to_f32#to_f16 on value.
Float64.new "20" # => 20.0
Float64.new " 20 ", whitespace: false # => Unhandled exception: Invalid Float64: 20 (ArgumentError)
Instance Method Detail
Returns true if self is greater than or equal to other.
Returns true if self is greater than or equal to other.
Returns true if self is greater than or equal to other.
Returns true if self is greater than or equal to other.
Returns true if self is greater than or equal to other.
Returns true if self is greater than or equal to other.
Returns true if self is greater than or equal to other.
Returns true if self is greater than or equal to other.
Returns true if self is greater than or equal to other.
Returns true if self is greater than or equal to other.
Returns true if self is greater than or equal to other.
Returns true if self is greater than or equal to other.
Rounds towards the nearest integer. If both neighboring integers are equidistant, rounds away from zero.
Rounds towards the nearest integer. If both neighboring integers are equidistant, rounds towards the even neighbor (Banker's rounding).
Returns self converted to Float64.
Raises OverflowError in case of overflow.
Returns self converted to Float64.
In case of overflow infinity is returned.
Returns self converted to Float64.
Raises OverflowError in case of overflow.
Returns self converted to Float64.
In case of overflow infinity is returned.
Returns self converted to Int32.
Raises OverflowError in case of overflow.
Returns self converted to Int32.
In case of overflow infinity is returned.
Returns self converted to Int128.
Raises OverflowError in case of overflow.
Returns self converted to Int128.
In case of overflow infinity is returned.
Returns self converted to Int16.
Raises OverflowError in case of overflow.
Returns self converted to Int16.
In case of overflow infinity is returned.
Returns self converted to Int32.
Raises OverflowError in case of overflow.
Returns self converted to Int32.
In case of overflow infinity is returned.
Returns self converted to Int64.
Raises OverflowError in case of overflow.
Returns self converted to Int64.
In case of overflow infinity is returned.
Returns self converted to Int8.
Raises OverflowError in case of overflow.
Returns self converted to Int8.
In case of overflow infinity is returned.
Prints a nicely readable and concise string representation of this object, typically intended for users, to io.
This method is called when an object is interpolated in a string literal:
"foo #{bar} baz" # calls bar.to_io with the builder for this string
IO#<< calls this method to append an object to itself:
io << bar # calls bar.to_s(io)
Thus implementations must not interpolate self in a string literal or call
io << self which both would lead to an endless loop.
Also see #inspect(IO).
Returns a nicely readable and concise string representation of this object, typically intended for users.
This method should usually not be overridden. It delegates to
#to_s(IO) which can be overridden for custom implementations.
Also see #inspect.
Returns self converted to UInt32.
Raises OverflowError in case of overflow.
Returns self converted to UInt32.
In case of overflow infinity is returned.
Returns self converted to UInt128.
Raises OverflowError in case of overflow.
Returns self converted to UInt128.
In case of overflow infinity is returned.
Returns self converted to UInt16.
Raises OverflowError in case of overflow.
Returns self converted to UInt16.
In case of overflow infinity is returned.
Returns self converted to UInt32.
Raises OverflowError in case of overflow.
Returns self converted to UInt32.
In case of overflow infinity is returned.
Returns self converted to UInt64.
Raises OverflowError in case of overflow.
Returns self converted to UInt64.
In case of overflow infinity is returned.
Returns self converted to UInt8.
Raises OverflowError in case of overflow.
Returns self converted to UInt8.
In case of overflow infinity is returned.