struct Float32
- Float32
- Float
- Number
- Value
- Object
Defined in:
bytes_ext.crConstructors
-
.from_be_bytes(bytes : Bytes) : Float32
Create a
Float32
value from its representation as a byte array in big endian. -
.from_bytes(bytes : Bytes, format : IO::ByteFormat = IO::ByteFormat::SystemEndian) : Float32
Create a
Float32
value from its representation as a byte array. -
.from_le_bytes(bytes : Bytes) : Float32
Create a
Float32
value from its representation as a byte array in little endian.
Instance Method Summary
-
#to_be_bytes : Bytes
Return the memory representation of this number as a byte array in big-endian (network) byte order.
-
#to_bytes(format : IO::ByteFormat = IO::ByteFormat::SystemEndian) : Bytes
Return the memory representation of this number as a byte array using the specified format
-
#to_le_bytes : Bytes
Return the memory representation of this number as a byte array in little-endian byte order.
Constructor Detail
Create a Float32
value from its representation as a byte array in big endian.
bytes = Bytes[0x41, 0x48, 0x00, 0x00]
Float32.from_be_bytes(bytes)
# => 12.5f32
Create a Float32
value from its representation as a byte array.
Create a Float32
value from its representation as a byte array in little endian.
bytes = Bytes[0x00, 0x00, 0x48, 0x41]
Float32.from_le_bytes(bytes)
# => 12.5f32
Instance Method Detail
Return the memory representation of this number as a byte array in big-endian (network) byte order.
bytes = "12.5f32".to_be_bytes
# => Bytes[0x41, 0x48, 0x00, 0x00]
Return the memory representation of this number as a byte array using the specified format
Return the memory representation of this number as a byte array in little-endian byte order.
bytes = 12.5f32.to_le_bytes
# => Bytes[0x00, 0x00, 0x48, 0x41]