Java Reference
In-Depth Information
A.3.4 More about floating-point
Additional notes of interest about Java floating-point include:
Literals default to double unless appended with f or F:
float x = 1.0; // compile time error
float x = 1.0f; // OK
double x = 1.0; // OK
Floating-point rounding:
The JVM uses IEEE 754 round-to-nearest mode: inexact results are rounded to the
nearest representable value, with ties going to the value with a zero least-significant
bit.
Instructions that convert values of floating-point types to integer values will round
towards zero.
See Section 10.14.3 for a discussion of bit operations on floating-point numbers
Resources
Joseph D. Darcy, What Everybody Using the Java TM Programming Language Should Know
About Floating-Point Arithmetic , Sun Microsystems, JavaOne Conference, 2002,
http://servlet.java.sun.com/javaone/sf2002/conf/sessions/
display-1079.en.jsp
David Flanagan, Java in a Nutshell , 4th edn, O'Reilly, 2002.
David Goldberg, What Every Computer Scientist Should Know About Floating-Point
Arithmetic , Computing Surveys, March 1991, http://docs.sun.com/source/
806-3568/ncg - goldberg.html
James Gosling, Bill Joy, Guy Steele, and Gilad Bracha, The Java Language Specification , 2nd
edn, Addison-Wesley, 2000. Available online at: http://java.sun.com/docs/
books/jls/second - edition/html/jTOC.doc.html.
Ronald Mak, Java Number Cruncher: The Java Programmer's Guide to Numerical
Computing , Prentice Hall, 2003.
Glen McCluskey, Some Things You Should Know about Floating-Point Arithmetic ,JavaTech
Tips, February 4, 2003, http://java.sun.com/developer/JDCTechTips/2003/
tt0204.html#2
Search WWH ::




Custom Search