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
Win a copy of
Practice Tests for OCP Java 17 Certification Exam (1Z0-829)
this week in the
OCPJP
forum!
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:
Tim Cooke
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Liutauras Vilda
Sheriffs:
Rob Spoor
Junilu Lacar
paul wheaton
Saloon Keepers:
Stephan van Hulst
Tim Moores
Tim Holloway
Carey Brown
Scott Selikoff
Bartenders:
Piet Souris
Jj Roberts
fred rosenberger
Forum:
Programmer Certification (OCPJP)
Why is this implicit cast legal?
Liang Anmian
Ranch Hand
Posts: 119
posted 17 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 17 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 17 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)
Don't get me started about those stupid
light bulbs
.
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...