It is always long 64-bit on both 32 and 64-bit machines

I am wondering how long is 64 bit in x86 and x64?

+6
source share
3 answers

Yes. Java long is 64 bits on any JVM without exception. All primitive Java types are fully portable and have fixed sizes in all implementations.

+27
source

Yes. A long is known as a 64-bit integer.

+4
source

Primitive types are always the same size. Only links can vary in size, but you donโ€™t need to know this at all.

You can get the size of the link with

 int addressSize = Unsafe.addressSize(); 

Note. Even in a 64-bit JVM (on the latest Java 6+ JVMs), the links are 32-bit, but if you are not using a bunch of 32 GB or more. This is the default value for OpenJDK / Sun / Oracle JDK, however, as @ user988052 notes, the IBM JVM needs the appropriate flag to be set on the command line. Other JVMs may not support this option at all.

+4
source

Source: https://habr.com/ru/post/905319/


All Articles