This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm not sure if my wording is exactly correct, so correct me if it's wrong.... It seems casting is necessary when initializing anything below a selected type on the list: double float long int short/char char/short byte
Example: double d = 9; float f = (float)d; //Cast necessary Question: 1) Example:
Why is casting necessary between float and long even though float is 32 bits and long is 64 bits? Long is bigger, there should be plenty of room. 2)Example:
I believe that short can hold an negative value, and char can't. So, a char can hold more than a short? and a cast is necessary. Why is a cast necessary both ways if one is bigger than the other? 3)Example:
Why is casting necessary both ways if char is 16 bits, and byte is 8 bits? 4)O'yea, by the way, thanks for you help!!!