Elaine Ware

Greenhorn
+ Follow
since Mar 10, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Elaine Ware

Thanks again, Jay. When is the rule for applying the formula? What is the logic behind the whole 2's compliment (complement?) paradigm? Thanks for the tutorial (I really did try to google the topic but was not successful).
Thanks Jay,
Now to expand the example. What would be the value of variable, b;

short s = 0x00FD;
byte b = (byte)s;

Based on your answer, I've figured that the bit representation for b
is
1111 1110

Is that correct? If so, then the decimal value is 254. However, the sample exam question says that the answer is -3. What am I missing?
[ March 11, 2005: Message edited by: Elaine Ware ]
Can someone explain two's compliment? I learned of it years back, but have since forgotten. How does it relate to knowing if a hexidecimal value is positive or negative? For example, how would on determine the decimal value (positive or negative) of the following:


short s = 0x00FD;

Thanks!
Thanks, everyone. I am very clear on this topic. I didn't memorize the 'widening conversion' chart past int.
Thanks all for responding. Then is the study guide incorrect? It says that long is 64 bits, while float is 32. Is that correct?
[ March 10, 2005: Message edited by: Elaine Ware ]
Hi All -- I'm using the "Complete Java 2 Certification Study Guide", 3rd ed., by Phillip Heller and Simon Roberts, Sybex 2002. In the preparation exam for J2 Programmer, the first question is as follows:

-- In the following code fragment, what are the legal data types for the variable, answer? (Choose all that apply)

byte b = 1;
char c = 2;
short s = 3;
int i = 4;
float f= = 5f;
answer = b*c*s*i*f;

A. byte
B. char
C. short
D. int
E. float
F. double
G. long

--

The correct choices are E,F. Why is G not correct? Thanks for the advice.
[ March 10, 2005: Message edited by: Elaine Ware ]