https://gcc.gnu.org/g:317c097a25fc401d838ea13f58b4d64c80496593

commit r16-8095-g317c097a25fc401d838ea13f58b4d64c80496593
Author: Jose E. Marchesi <[email protected]>
Date:   Sat Mar 14 16:58:53 2026 +0100

    a68: fix float standard conversion routine
    
    This commit fixes the implementation of the `float' standard
    conversion routine, by amending a typo that originates in the Revised
    Report.  It also makes the routine to properly handle short short and
    short int arguments.
    
    Signed-off-by: Jose E. Marchesi <[email protected]
    
    libga68/ChangeLog
    
            * standard.a68.in (float): Fix typo from RR and handle short* int
            arguments properly.
    
    gcc/testsuite/ChangeLog
    
            * algol68/execute/float-1.a68: New test.

Diff:
---
 gcc/testsuite/algol68/execute/float-1.a68 |  3 +++
 libga68/standard.a68.in                   | 13 +++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/algol68/execute/float-1.a68 
b/gcc/testsuite/algol68/execute/float-1.a68
new file mode 100644
index 000000000000..1c3531bfe873
--- /dev/null
+++ b/gcc/testsuite/algol68/execute/float-1.a68
@@ -0,0 +1,3 @@
+begin assert(float(123.4567,12,5,2) = "+12.34567e+1");
+      assert(float(123.4567,-10,5,-1) = " 1.23457e2")
+end
diff --git a/libga68/standard.a68.in b/libga68/standard.a68.in
index 6d543e7cff86..5246679fa9f6 100644
--- a/libga68/standard.a68.in
+++ b/libga68/standard.a68.in
@@ -114,21 +114,26 @@ def
         case v in
            {iter L  {} {long}  {long long}}
            {iter L_ {} {long_} {long_long_}}
+           {iter S  {} {LENG}  {LENG LENG}}
            ({L} real x):
               if int before = ABS width - ABS exp - (after /= 0 | after+1 | 0) 
- 2;
                  SIGN before + SIGN after > 0
               then string s, {L} real y := ABS x, int p := 0;
                    {L_}standardize (y, before, after, p);
-                   s := fixed (SIGN (x * y), SIGN width * (ABS width - ABS exp 
- 1),
-                               after) + "*^" + whole (p, exp);
+                   s := fixed ({S} SIGN x * y, SIGN width * (ABS width - ABS 
exp - 1),
+                               after) + "e" + whole (p, exp);
                    if exp = 0 OR char_in_string (errorchar, loc int, s)
                    then float (x, width, (after /= 0 | after-1 | 0),
                                (exp > 0 | exp+1 | exp-1))
                    else s
                    fi
               else { XXX undefined } skip; ABS width * errorchar
-              fi,
-           ({L} int x): float ({L} real (x), width, after, exp)
+              fi
+           {reti {,}}
+           ,
+           {iter L {short short} {short} {} {long} {long long}}
+           {iter R {LENG LENG} {LENG} {} {} {}}
+           ({L} int x): float ({L} real ({R} x), width, after, exp)
            {reti {,}}
         esac;

Reply via email to