1

Is the static method toHexString() of Integer and Long dependent on the system endian, that is does it vary between little endian and big endian platforms?

Does

final String hex = Integer.toHexString(123456);
System.out.println(hex);

always print 1e240 on every supported Java platform?

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
Vertex
  • 2,682
  • 3
  • 29
  • 43
  • Yes. The JVM guarantees it. Anyway, I think it's [Big Endian](http://stackoverflow.com/questions/981549/javas-virtual-machines-endianness). – Elliott Frisch Nov 30 '13 at 00:47

1 Answers1

1

Yes, the representation will always be the same. See Integer.toHexString(int) and Java's Virtual Machine's Endianness

Community
  • 1
  • 1
Johnbot
  • 2,169
  • 1
  • 24
  • 24
  • Thanks. The JavaDoc of `toHexString` doesn't explain the endianess but the second link tells me, that all integer operands with more than one byte are stored in the big endian format. – Vertex Nov 30 '13 at 01:05