# Elaine Ware

Greenhorn
since Mar 10, 2005
For More
Cows and Likes
Cows
0
In last 30 days
0
Total given
0
Likes
0
0
Total given
0
Given in last 30 days
0
Scavenger Hunt
Ranch Hand Scavenger Hunt
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).
19 years ago
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 ]
19 years ago
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!
19 years ago
Thanks, everyone. I am very clear on this topic. I didn't memorize the 'widening conversion' chart past int.
19 years ago
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 ]
19 years ago
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;

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 ]
19 years ago