On 9/3/19 5:52 PM, yary wrote:
I'm puzzled what you really want, what the end goal is.

For looking at different representations of the same item, "pack" and "unpack" are useful. I've only used the perl5 versions of those, for p6 it is "experimental". Different machines will represent the same real differently, and if I recall correctly not even IEEE standards exactly specify representation of float and it can vary by compiler too.

Perl 6's native experimental pack/unpack don't support real, nor does the P5pack module, so reverting to perl5... big/little b/h is binary or hex in big/little-endian order. With quoting that should work in either Win or Unix

$ perl -E "say unpack 'b*',pack 'f', 12.34"
00100101000011101010001010000010
$ perl -E "say unpack 'B*',pack 'f', 12.34"
10100100011100000100010101000001
$ perl -E "say unpack 'h*',pack 'f', 12.34"
4a075414
$ perl -E "say unpack 'H*',pack 'f', 12.34"
a4704541



Thank you!

What is the difference between b*, B*, h*, and H* ?


$ perl -E "say unpack 'b*',pack 'f', 11.00"
00000000000000000000110010000010

$ perl -E "say unpack 'b*',pack 'f', 11.01"
01101111000101000000110010000010

$ perl -E "say unpack 'b*',pack 'f', 10.999999999"
00000000000000000000110010000010

Reply via email to