-2

What I understood in a very naive way about 32 bit vs 64 bit processors is: On 32 bit, an 'int' is represented as 32 bits but n 64 bit processor, int is represented as 64 bit. IS it right? IS this the only difference? From this over simplification, it is not clear why 64 bit is 'better' than 32 bit.

My other question is: If I have a simple client server application(java) where client is 32 bit and server is 64 bit, will that cause a problem when data is transferred between client and server?

Victor
  • 16,609
  • 71
  • 229
  • 409
  • If your client and server send data over the wire in a way that's affected by the architecture, your protocol has been designed very badly. The broader question is more suited to wikipedia. – Wooble Jan 16 '14 at 18:26
  • 2
    No, almost any programming language that generates 64-bit code keeps an *int* at 32-bits. A *pointer* is 64 bits. Addresses. Big data types are expensive, you don't get bigger CPU caches. – Hans Passant Jan 16 '14 at 18:29

1 Answers1

0

In virtually every case, what makes a CPU 64-bits is the number of bits in the general-purpose registers, and as a consequence, the number of bits in a memory address.

Sadly, the C "int" does not vary with CPU size, and neither does the size of any other type AFAIK.

64-bit and 32-bit (and 16-bit and 8-bit) CPUs can process 8, 16, 32 and 64 bit integers [and floating point]. What they cannot all do is address memory with 64-bit addresses [or 32-bit addresses in the case of 16-bit and 8-bit CPUs].

Therefore, it does not matter what size CPU a client or server program is running on. What CAN matter, if the author of the program is not aware of CPU architecture issues, is that without careful specification, data sent by different CPUs can send their bytes in different order (like the 8-bytes of a 64-bit integer or floating-point number) and/or assume the bytes are in a different order.

My advice is to always order data to be transmitted in "little endian" order, because there IS only one little endian order. Sadly, there are several versions of big endian order, depending on CPU register/address size and CPU conventions for data-types larger than their register sizes. But not everyone agrees with me about this point.

honestann
  • 1,374
  • 12
  • 19