[GODCC][COMMITTED] utils.a68: simplify itoa
Jose E. Marchesi
jemarch@gnu.org
Wed Mar 19 07:52:27 GMT 2025
---
src/utils.a68 | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/src/utils.a68 b/src/utils.a68
index 8b4e34a..5029012 100644
--- a/src/utils.a68
+++ b/src/utils.a68
@@ -42,20 +42,19 @@ BEGIN
END;
PROC itoa = (INT i) STRING:
-BEGIN IF i = 0
- THEN "0"
- ELSE INT n := ABS i;
- STRING res;
- WHILE n /= 0
- DO INT rem = n %* 10;
- res := REPR (rem > 9
- | (rem - 10) + ABS "a"
- | rem + ABS "0") + res;
- n %:= 10
- OD;
- (i < 0 | "-" + res | res)
- FI
-END;
+ IF i = 0
+ THEN "0"
+ ELSE INT n := ABS i;
+ STRING res;
+ WHILE n /= 0
+ DO INT rem = n %* 10;
+ res := REPR (rem > 9
+ | (rem - 10) + ABS "a"
+ | rem + ABS "0") + res;
+ n %:= 10
+ OD;
+ (i < 0 | "-" + res | res)
+ FI;
PROC char in string = (STRING s, CHAR c) INT:
BEGIN INT res := 0, BOOL found := FALSE;
--
2.30.2
More information about the Algol68
mailing list