Is primitive data variable length limited by computer hardware ?

  • Thread starter lonelyplanet999
  • Start date
L

lonelyplanet999

Hi,

I'm studying 310-035 exam. The textbook available said that long data
type variable is of 64 bits (so are double type variable). However,
when I tested program in my Pentium 166 notebook w/ windows 98 OS, I
found that long data variable is only of 32 bits wide.

I found operation 1<<32 output 1 instead of 2 to the power of 32.

I would like to ask will java support 64 bits variables only if the
computer hardware (e.g. processor, data bus) supports 64 bits data
transfer ?

Tks :)
 
T

Thomas Schodt

Numeric literals are 32 bit integers.

Try this:

class longTest {
public static void main(String[] argv) {
System.out.println(1<<32);
System.out.println(1L<<32);
}
}
 
S

Sudsy

lonelyplanet999 said:
Hi,

I'm studying 310-035 exam. The textbook available said that long data
type variable is of 64 bits (so are double type variable). However,
when I tested program in my Pentium 166 notebook w/ windows 98 OS, I
found that long data variable is only of 32 bits wide.

I found operation 1<<32 output 1 instead of 2 to the power of 32.

Try 1L << 32 (the trailing L indicates that the number is long).
 
D

Dale King

lonelyplanet999 said:
Hi,

I'm studying 310-035 exam. The textbook available said that long data
type variable is of 64 bits (so are double type variable). However,
when I tested program in my Pentium 166 notebook w/ windows 98 OS, I
found that long data variable is only of 32 bits wide.

How did you find that out since it is not true.
I found operation 1<<32 output 1 instead of 2 to the power of 32.

Because the << operator takes the right hand operand and does a modulus with
the size of the left hand type. Since 1 is an int constant it has a width of
32 so a modulus of 32 is done with the right hand operand. That means 1 <<
32 is exactly the same as 1 << 0.

And note that this has no bearing on the question of longs being 64 bits
because your expression contained no long data types. If you try with a long
constant as in 1L you will find that 1L << 32 will give you the answer you
expect.
I would like to ask will java support 64 bits variables only if the
computer hardware (e.g. processor, data bus) supports 64 bits data
transfer ?

Perhpas for J2ME, but for J2SE long must be supported.
 
?

=?ISO-8859-1?Q?Thomas_Gagn=E9?=

What will jave do when the first 128-bit chips become available? Will
that be a long long?

Roedy said:
No. long is always 64 bits.
<snip
 
R

Roedy Green

What will jave do when the first 128-bit chips become available? Will
that be a long long?

For addressing, 64 bits aught to hold us quite a while. The size of an
address is invisible in Java.

They could do that, mainly to avoid creating a new keyword. I would
prefer a new keyword, e.g. wide.
 
N

nos

intel has 128 floating point today
even 64 bit processors don't use all 64 bits for addressing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Java decode alternative 0
Java decode alternative 2
Java decode alternative 0
data types (bitwidth) and multiplication 9
Overclocking Guide 0
machine code for Java 1
Overclocking Guide 0
.knafulghkuakug 1

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top