[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/48359] ARM SOFTFP double to ascii issue still there
From: |
gert.brettlecker at ergon dot ch |
Subject: |
[Bug classpath/48359] ARM SOFTFP double to ascii issue still there |
Date: |
Thu, 31 Mar 2011 13:57:25 +0000 |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48359
--- Comment #1 from Gert Brettlecker <gert.brettlecker at ergon dot ch>
2011-03-31 13:57:21 UTC ---
I applied the following patch for this situation on my ARM platform.
This will loose precision on denormalized numbers (smaller than DBL_MIN) but it
does not assert anymore:
--- classpath-0.98/native/jni/java-lang/java_lang_VMDouble.c
+++ classpath-0.98/native/jni/java-lang/java_lang_VMDouble.c
@@ -42,6 +42,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <float.h>
#include "mprec.h"
#include "fdlibm.h"
@@ -422,7 +423,10 @@
do {
jdouble parsed_value;
- assert(least_necessary_precision <= maximal_precision);
+ if (least_necessary_precision>maximal_precision) {
+ fprintf (stderr, "java.lang.VMDouble.toString error reaching
maximal_precision value = %g\n", value);
+ break;
+ }
/* Convert the value to a string and back. */
dtoa_toString(buf, value, least_necessary_precision, isFloat);
@@ -433,10 +437,14 @@
/* We need to cast floats to float to make sure that our ineqality check
works
* well for floats as well as for doubles.
*/
- parsed_value_unequal = ( isFloat ?
- (float) parsed_value != (float) value :
- parsed_value != value);
-
+ if (isFloat) {
+ parsed_value_unequal = ((float) parsed_value != (float) value) ;
+ } else if (parsed_value>value) {
+ parsed_value_unequal = ((parsed_value-value) > DBL_MIN);
+ } else {
+ parsed_value_unequal = ((value-parsed_value) > DBL_MIN);
+ }
+
least_necessary_precision++;
}
while (parsed_value_unequal);
Someone has a better idea?
Cheers
Gert