Can any one here help me out to understand how the below floating point directives work in Ruby with packing() and unpacking()
method?
D and d
F and f
g and G
e and E
I have tried below:
irb(main):001:0> [2,44,43].pack('D')
=> "\x00\x00\x00\x00\x00\x00\x00@"
irb(main):002:0> [2,44,43].pack('d')
=> "\x00\x00\x00\x00\x00\x00\x00@"
irb(main):004:0> [2,44,43].pack('ddd')
=> "\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00F@\x00\x00\x00\x00\x00\
x80E@"
irb(main):005:0> [2,44,43].pack('fff')
=> "\x00\x00\x00@\x00\x000B\x00\x00,B"
irb(main):006:0> [2,44,43].pack('FFF')
=> "\x00\x00\x00@\x00\x000B\x00\x00,B"
irb(main):007:0> [2,44,43].pack('ggg')
=> "@\x00\x00\x00B0\x00\x00B,\x00\x00"
irb(main):008:0> [2,44,43].pack('GGG')
=> "@\x00\x00\x00\x00\x00\x00\x00@F\x00\x00\x00\x00\x00\x00@E\x80\x00\x00\x00\x0
0\x00"
irb(main):009:0>
How the output is coming? what the logic of such computation?
Thanks in advance!