[COMMITTED] algol68: implement a68_real_exp_width

Jose E. Marchesi jemarch@gnu.org
Sat Mar 15 20:03:47 GMT 2025


---
 gcc/algol68/a68-low-reals.cc | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/gcc/algol68/a68-low-reals.cc b/gcc/algol68/a68-low-reals.cc
index 05bb2e96355..b76a821283a 100644
--- a/gcc/algol68/a68-low-reals.cc
+++ b/gcc/algol68/a68-low-reals.cc
@@ -40,6 +40,8 @@
 #include "dumpfile.h"
 #include "convert.h"
 
+#include "math.h" /* For log10 */
+
 #include "a68.h"
 
 static tree
@@ -119,8 +121,13 @@ a68_real_width (tree type)
 tree
 a68_real_exp_width (tree type ATTRIBUTE_UNUSED)
 {
-  /* XXX */
-  return build_int_cst (a68_int_type, 0);
+  const machine_mode mode = TYPE_MODE (type);
+  const struct real_format *fmt = REAL_MODE_FORMAT (mode);
+  const double log10_2 = .30102999566398119521;
+  double log10_b = log10_2;
+  int max_10_exp = fmt->emax * log10_b;
+
+  return build_int_cst (a68_int_type, 1 + log10 (max_10_exp));
 }
 
 /* Given a real value VAL, return -1 if it is less than zero, 0 if it is zero
-- 
2.30.2



More information about the Algol68 mailing list