0

I am doing some low level bit manipulation in Ruby and was wondering if there was the Ruby equivalent of the htonl() and ntohl() functions in C?

I came across the .pack method, but does [1024].pack("N") provide a suitable replacement for htonl?

Chris
  • 1,101
  • 2
  • 9
  • 14
  • This should help: https://idiosyncratic-ruby.com/4-what-the-pack.html – Fiddling Bits Oct 13 '18 at 23:17
  • I think this question has been asked already: https://stackoverflow.com/questions/12706052/ruby-how-to-convert-32-bit-integer-to-network-byte-order . Hope that helps. – wteuber Oct 13 '18 at 23:38

0 Answers0