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)
float has some problem. see the code...
Ajay Chandravadiya
Greenhorn
Posts: 27
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
long l = 100l; float f = 100.01f; float z = l + f ; System.out.println(z);
output:
200.0100
1
where are we getting that extra 1 from?
SCJP Tiger Hunter 91%.
Jesper de Jong
Java Cowboy
Posts: 16084
88
I like...
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This is to be expected, because the
float
datatype is not infinitely precise. In fact float is accurate up to about 6 decimal digits.
For some more background info, see:
Floating point - Accuracy problems
Jesper's Blog
-
Pluralsight Author Page
It means our mission is in jeapordy! Quick, read this 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
Scripting with JSTL Core tags.
Argument Scope
primitive widening doubt
How this assignment is possible...?
wrappers
More...