Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

32 bit and 64 bit systems

 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 byte is composed of 8 bits. Thats the legacy.

Now for the newer systems of 32 bits and 64 bits, is byte size still 8 bit or is 1 byte equal to 32 bits in 32 bit system and 64 bits in g4 bit system ?

So when we declare integer in 32 bit system is it 1 byte (32 bits) or 4 bytes (8 bits) ?

How does it work with 64 bit system ?

Thanks
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 byte is always 8 bits.

How many bits an "integer" data type comprises depends on the language in question. In Java, an "int" always has 32 bits, and a "long" 64 bit. That's independent of whether the underlying system has 32 bit hardware or 64 bit hardware.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or even if the hardware is 48 bits!
 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 byte is always 8 bits.

How many bits an "integer" data type comprises depends on the language in question. In Java, an "int" always has 32 bits, and a "long" 64 bit. That's independent of whether the underlying system has 32 bit hardware or 64 bit hardware.
Thanks.

I was confused that 32 bit and 64 bits are the sizes for byte in newer systems. Then what does 32 bit and 64 bit system indicate ? What 32 and 64 bits indicate ? Which component do they refer to ?

 
Henry Wong
author
Marshal
Pie
Posts: 21115
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nirjari patel wrote: Thanks.

I was confused that 32 bit and 64 bits are the sizes for byte in newer systems. Then what does 32 bit and 64 bit system indicate ? What 32 and 64 bits indicate ? Which component do they refer to ?


In processor speak, a 64 bit system has a 64 bit bus, with 64 bit registers, and has instructions that can operate on those 64 bit registers. So, as an example (let's say in C), if you try to add two long values, the C compiler can generate a single instruction for that operation on a 64 bit environment. For a 32 bit environment, the compiler would generate code that operate on the 64 bit long variable, 32 bits at a time, dealing with the carry, etc. in order to perform the same operation. This means that the 32 bit generated code is longer (has lots more instructions) and of course, will take longer to run.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic