0

如何将浮点数转换为little-endian 格式的字节

5.05 -> \x33\x33\x33\x33\x33\x33\x14\x40
4

1 回答 1

4

像这样:

# let v = Int64.bits_of_float 5.05 in
  for i = 0 to 7 do
    Printf.printf "%Lx " (Int64.logand 255L (Int64.shift_right v (i*8))) ;
  done 
  ;;
33 33 33 33 33 33 14 40 - : unit = ()
于 2013-04-25T15:43:48.540 回答