Re: How to handle floats and avoid NaN




Oliver Wong wrote:
> "Roedy Green" <look-on@xxxxxxxxxxxxxxxxxxxx> wrote in message
> news:edquh1hmapi6q7me2af7lkoq7968l96ptm@xxxxxxxxxx
> > On 7 Sep 2005 08:34:35 -0700, mehtakrishna2002@xxxxxxxxx wrote or
> > quoted :
> >
> >>I am trying to do some matrix manipulation using a matrix module in
> >>java that i downloaded from the web. When I deal with large matrices
> >>(60x60), I start getting NaN for a lot of my calculations. I think It
> >>is due to the way in which Java handles floats.
> >
> > 1. use doubles
> > 2. check earlier for NaNs rather than letting them propagate in
> > useless calculation.
> >
> > The problem is essentially some mathematical algorithms sometimes
> > produce infinities.
>
> AFAIK, IEEE standards (which Java uses), has values for positive and
> negative infinity which are distinct from NaN.

You are correct, but producing infinities can subsequently lead to
NaNs,
e.g., if you compute Infinity - Infinity.

.



Relevant Pages

  • Re: Calculus XOR Probability
    ... have a number, so it's NaN. ... What kind of math can you do on a Java ... similarly any operation involving an infinity operand results in either ... You described counting the size of a finite set. ...
    (sci.math)
  • Re: Calculus XOR Probability
    ... have a number, so it's NaN. ... What kind of math can you do on a Java ... similarly any operation involving an infinity operand results in either ... You described counting the size of a finite set. ...
    (sci.math)
  • Re: Calculus XOR Probability
    ... have a number, so it's NaN. ... What kind of math can you do on a Java ... similarly any operation involving an infinity operand results in either ... You described counting the size of a finite set. ...
    (sci.math)
  • Re: How to handle floats and avoid NaN
    ... > I am trying to do some matrix manipulation using a matrix module in ... I start getting NaN for a lot of my calculations. ... > is due to the way in which Java handles floats. ...
    (comp.lang.java.programmer)
  • Re: How to handle floats and avoid NaN
    ... I start getting NaN for a lot of my calculations. ... >>is due to the way in which Java handles floats. ... negative infinity which are distinct from NaN. ...
    (comp.lang.java.programmer)