class Float
Public Instance Methods
to_fixed16_8()
click to toggle source
Converts a float to a 16-bit fixed point twos complement number formatted: iiiiiiiiffffffff where i represents the absolute integer part bits and f represents the fractional part bits.
# File lib/z80lib3d/fixed_float.rb, line 5 def to_fixed16_8 n = (self * 256.0).round raise ArgumentError if n >= 32768 || n <= -32768 n & 0xffff end
to_z80bin(simplified_int=true)
click to toggle source
Converts Float
to a ZX-Spectrum's real number encoded as a 5-byte binary string.
Suitable to be used with ZXLib::Math::ZXReal
struct for data.
simplified_int
indicates if integers in the range of -65535..65535 should be stored in a simplified integer form.
Returns binary string.
# File lib/zxlib/math.rb, line 13 def to_z80bin(simplified_int=true) ::ZXLib::Math.pack_number self, simplified_int end