# Java's new Floating-point math

Jan 17, 2009, 22:03 (0 Talkback[s])
(Other stories by Elliotte Rusty Harold)

### WEBINAR:

On-Demand

Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js

*[ Thanks to An Anonymous Reader for
this link. ]*

"Version 5 of the Java Language Specification added 10
new methods to java.lang.Math and java.lang.StrictMath, and Java 6
added another 10. Part 1 of this two-article series looked at the
new methods that make sense mathematically. That is, they provide
functions that a pre-computer-era mathematician would find
familiar. Here in Part 2, I focus on the functions that make sense
only when you realize that they're designed for operating on
floating-point numbers instead of abstract real numbers.
"As I noted in Part 1, the distinction between a real number
such as e or 0.2 and its computer representation such as a Java
double is an important one. The Platonic ideal of the number is
infinitely precise, whereas the Java representation has only a
fixed number of bits (32 for a float, 64 for a double) to work
with. The maximum value of a float is about 3.4*1038, which isn't
large enough for some things you might wish to represent, such as
the number of electrons in the universe."

Complete
Story

**Related Stories:**