class Depix::Binary::Fields::R32Field

real32 field. Now, there is some lap dancing to be done here. The DPX files in the wild define nonexistant data as a charfield with all it's bits set (four times 0xFF byte). This is easy to verify with a string but practically useless once the charfield has been unpacked into a float. Therefore we first unpack the value as a charfield, then we check whether it's all blanking, and if it is we return nil. If it's not “all bits set” though what we will do is try to decode it again using the real float unpack pattern. The same dance happens reciprocally when repacking the data.

Constants

BLANK
PATTERN_BE
PATTERN_LE

Public Instance Methods

clean(v) click to toggle source
# File lib/depix/binary/fields.rb, line 180
def clean(v)
  (v.nil? || v.nan?) ? nil : v
end
length() click to toggle source
# File lib/depix/binary/fields.rb, line 184
def length
  4
end
pack(value) click to toggle source

The packing of NaN

12

pry(main)> value = 0 / 0.0

> NaN

13

pry(main)> [value].pack(“g”)

> “xFFxC0x00x00”

14

pry(main)> [value].pack(“g”)

# File lib/depix/binary/fields.rb, line 198
def pack(value)
  (value.nil? || value.nan? ) ? BLANK : [value].pack("g")
end
pattern() click to toggle source
# File lib/depix/binary/fields.rb, line 176
def pattern
  "g"
end
rtype() click to toggle source
# File lib/depix/binary/fields.rb, line 188
def rtype
  Float
end