Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
Why is this implicit cast legal?
Liang Anmian
Ranch Hand
Posts: 119
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
If I have this:
float f = 123L;
why does the code compile? A long variable is 8 bytes, while a float variable is 4 bytes. In theory, a float is not large enough to hold 8 bytes.
Current Status:<br /> <br />SCJP 1.4<br />SCJD (in progress)
Steven Bell
Ranch Hand
Posts: 1071
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
A float is a wider type. It has a larger range of values than a long does. Even though there may be loss of precision
Java
allows casting into wider types.
Liang Anmian
Ranch Hand
Posts: 119
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Ok thanks a lot.
Current Status:<br /> <br />SCJP 1.4<br />SCJD (in progress)
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
primitive types assignment
why ceil & floor accepts int
about interface
primitive types
primitive types
More...