[Ecls-list] Immediate short-float for ECL

Lars Brinkhoff lars at nocrew.org
Mon Oct 23 13:30:45 UTC 2006


"Juan Jose Garcia-Ripoll" <juanjose.garciaripoll at googlemail.com> writes:
> ECL compiles and passes the test suite except for a number of
> problems, many of them related to rounding errors, probably some
> typos left (float instead of long double, etc) that remove
> precision, etc.

I added --enable-short-float and AC_DEFINE(ECL_SHORT_FLOAT...) to
configure.in (not included in this patch), and here are some things I
had to fix to make ecl_min compile.  The full ecl doesn't compile yet.

Also a fix for printing short/single-float.

Index: c/hash.d
===================================================================
RCS file: /project/ecl/cvsroot/ecl/src/c/hash.d,v
retrieving revision 1.43
diff -u -r1.43 hash.d
--- c/hash.d	13 Oct 2006 17:28:51 -0000	1.43
+++ c/hash.d	23 Oct 2006 13:19:49 -0000
@@ -219,14 +219,13 @@
 		return h;
 	case t_fixnum:
 		return hash_word(h, fix(x));
-#ifdef HAVE_SHORT_FLOAT
+#ifdef ECL_SHORT_FLOAT
 	case t_shortfloat: {
 		/* FIXME! We should be more precise here! */
-		return hash_word(h, (cl_index)sf(x));
-		union { float f; cl_index w; } x;
-		x.w = 0;
-		x.f = ecl_short_float(x);
-		return hash_word(h, x.w);
+		union { float f; cl_index w; } y;
+		y.w = 0;
+		y.f = ecl_short_float(x);
+		return hash_word(h, y.w);
 	}
 #endif
 	case t_singlefloat:
Index: c/num_arith.d
===================================================================
RCS file: /project/ecl/cvsroot/ecl/src/c/num_arith.d,v
retrieving revision 1.25
diff -u -r1.25 num_arith.d
--- c/num_arith.d	13 Oct 2006 17:28:52 -0000	1.25
+++ c/num_arith.d	23 Oct 2006 13:19:49 -0000
@@ -843,7 +843,7 @@
 
 #ifdef ECL_SHORT_FLOAT
 	case t_shortfloat:
-		return make_shortfloat(-ecl_shortfloat(x));
+		return make_shortfloat(-ecl_short_float(x));
 #endif
 	case t_singlefloat:
 		z = cl_alloc_object(t_singlefloat);
Index: c/num_co.d
===================================================================
RCS file: /project/ecl/cvsroot/ecl/src/c/num_co.d,v
retrieving revision 1.33
diff -u -r1.33 num_co.d
--- c/num_co.d	22 Oct 2006 19:03:47 -0000	1.33
+++ c/num_co.d	23 Oct 2006 13:19:49 -0000
@@ -812,9 +812,13 @@
 		VALUES(1) = make_ratio(VALUES(1), x->ratio.den);
 		break;
 #ifdef ECL_SHORT_FLOAT
-	case t_shortfloat:
-		f = ecl_short_float(x);
-		goto FLOAT;
+	case t_shortfloat: {
+		float d = ecl_short_float(x);
+		float q = round_double(d);
+		VALUES(0) = float_to_integer(q);
+		VALUES(1) = make_singlefloat(d - q);
+		break;
+	}
 #endif
 	case t_singlefloat: {
 		float d = sf(x);
@@ -1260,7 +1264,7 @@
 	case t_bignum:
 	case t_ratio:
 #ifdef ECL_SHORT_FLOAT
-	case t_longfloat:
+	case t_shortfloat:
 #endif
 	case t_singlefloat:
 	case t_doublefloat:
Index: c/number.d
===================================================================
RCS file: /project/ecl/cvsroot/ecl/src/c/number.d,v
retrieving revision 1.35
diff -u -r1.35 number.d
--- c/number.d	13 Oct 2006 17:29:27 -0000	1.35
+++ c/number.d	23 Oct 2006 13:19:49 -0000
@@ -364,7 +364,7 @@
 #endif /* WITH_GMP */
 	}
 #ifdef ECL_SHORT_FLOAT
-	case t_singlefloat:
+	case t_shortfloat:
 		return ecl_short_float(x);
 #endif
 	case t_singlefloat:
Index: c/print.d
===================================================================
RCS file: /project/ecl/cvsroot/ecl/src/c/print.d,v
retrieving revision 1.96
diff -u -r1.96 print.d
--- c/print.d	13 Oct 2006 20:51:48 -0000	1.96
+++ c/print.d	23 Oct 2006 13:19:49 -0000
@@ -1078,16 +1078,16 @@
 #ifdef ECL_SHORT_FLOAT
 	case t_shortfloat:
 		r = symbol_value(@'*read-default-float-format*');
-		write_double(ecl_short_float(x), (r == @'short-float')? 0 : 'f', FLT_SIG, stream);
+		write_double(ecl_short_float(x), (r == @'short-float')? 0 : 's', FLT_SIG, stream);
 		break;
 	case t_singlefloat:
 		r = symbol_value(@'*read-default-float-format*');
-		write_double(sf(x), (r == @'single-float')? 0 : 's', FLT_SIG, stream);
+		write_double(sf(x), (r == @'single-float')? 0 : 'f', FLT_SIG, stream);
 		break;
 #else
 	case t_singlefloat:
 		r = symbol_value(@'*read-default-float-format*');
-		write_double(sf(x), (r == @'single-float' || r == @'short-float')? 0 : 's', FLT_SIG, stream);
+		write_double(sf(x), (r == @'single-float' || r == @'short-float')? 0 : 'f', FLT_SIG, stream);
 		break;
 #endif
 #ifdef ECL_LONG_FLOAT
Index: c/read.d
===================================================================
RCS file: /project/ecl/cvsroot/ecl/src/c/read.d,v
retrieving revision 1.125
diff -u -r1.125 read.d
--- c/read.d	13 Oct 2006 20:49:40 -0000	1.125
+++ c/read.d	23 Oct 2006 13:19:50 -0000
@@ -472,6 +472,7 @@
 		case 's':  case 'S':
 #ifdef ECL_SHORT_FLOAT
 			output = make_shortfloat(d);
+			break;
 #endif
 		case 'f':  case 'F':
 			output = make_singlefloat(d);




More information about the ecl-devel mailing list