Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
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:
Beginning Java
widening
Puspender Tanwar
Ranch Hand
Posts: 658
2
I like...
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
class ABC{ public static void main(String args[]) { int a=1234567890; float x=a; System.out.println(a-(int)x); } }
The output of code is
-46
. Now the point is if both the variables are having same value. Than why not the difference is
0
?
if I write the value 123, I get
0
as output
help me out !!!
Tushar Goel
Ranch Hand
Posts: 954
4
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
try to print values of both the variables separately then you can see the difference.
Tushar Goel
Ranch Hand
Posts: 954
4
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Also if you google the difference between float and int then you will see both are different
Campbell Ritchie
Marshal
Posts: 79177
377
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Please tell us where
that example comes from
. There is a similar example to show such imprecision in the
Java
Language Specification.
What a show! What atmosphere! What fun! What a tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
strange conversion??
Primitive Conversion
Widening conversion from int to float..
loss of precision float and double
Overloading with varargs
More...