Mittwoch, 1. April 2009

Die Programmierung, unendliche Weiten... Java: Math.log(0) = -Infinity (double)

Die Unendlichkeit ist so ein Thema für sich. Ich habe heute einen Fehler in der Java-Komponente JFreeChart gemeldet. Es kommt zu einer niemals endenden while-Schleife, da das Ergebnis von Math.log(0) auf meinem System -Infinity (Variablentyp: double) ist und das in einer while-Schleife verwendet wird.
Bei einem Kollegen mit Mac OS als Betriebsystem und dem gleichen Quelltext führt das aber komischerweise nicht zum Fehler - werde Ihn mal fragen was Math.log(0) bei Ihm liefert :)

Hier meine Fehlerbeschreibung:

Summary: endless loop in LogAxis class

Description:

JFreeChart Version 1.0.12
OS: Linux (Kernel: 2.6.27-14)
JVM: sun-java 1.6.0_10-b33
Architecture: x86_64

I get an endless loop in LogAxis.refreshTicksVertical method. This method
calls calculateLog(getLowerBound())-method. getLowerBound() returns 0.0d
and calculateLog calls Math.log on number 0. the result of Math.log(0) =
-Infinity on my system and this is the cause of the endless loop in
LogAxis.refreshTicksVertical - while (current <= end) -
current = -Infinity - is every time true.
I have added a zero (0) check to calculateLog and now everything seems to
work.

A colleague with Mac OS operating system does not have the problem with
the same code.

The class LogarithmicAxis seems to work out of the box - seems to have a
zero check already included (SMALL_LOG_VALUE = 1e-100).


Hier der Link zum Ticket bei sourceforge: link

Update: auf dem Mac gibt Math.log(0) auch -Infitity.

Keine Kommentare:

Kommentar veröffentlichen