0

I'm trying to convert a byte array to and from a Boost number with the cpp_int backend. What is a portable way to do this?

The platforms I'm concerned about are all little endian, but can be 32 or 64 bit and can be compiled with different compilers. Some of the ways I've seen to do this break depending on compiler versions and such, and that's what I want to avoid.

Earlz
  • 62,085
  • 98
  • 303
  • 499

1 Answers1

0

The only real difference between x86 and x64 is the size of pointers. So unless it relies on the size of pointers somehow, there shouldn't be much of a problem. Especially since a byte is always 8bits and you already ruled out endiannes problems.

  • I found this http://stackoverflow.com/questions/15720841/boost-multiprecision-cpp-int-convert-into-an-array-of-bytes but that seems to use different storage methods depending on if the compiler supports 128bit integers or not – Earlz Sep 02 '16 at 20:50