Hello Chris.

I have just pushed the patch on your behalf.
Thank you so much, and congratulations on your first GCC patch!

> This is version 5 of a patch to replace the GNU Algol 68
> proc whole and its dependencies, and to add whole-1.a68
> to the test directory.
>
> -- 
> Chris Hermansen
>
> From dba1c7a7cc3103f2ff97d7b8b4c215df88867360 Mon Sep 17 00:00:00 2001
> From: Chris Hermansen <[email protected]>
> Date: Thu, 16 Jul 2026 15:27:52 -0700
> Subject: [PATCH] Version 5 of proc whole, dependencies and test
>
> A replacement for proc whole provided in the Revised Report on p.159.
>
> Several factors motivated me to propose this replacement for the RR code.
>
> Most importantly, the RR whole fails for an argument value of -max_int - 1, as
> well as any short short, short, long or long long equivalents, because the RR
> version applies the operator ABS to the argument, and on any hardware using
> twos-complement representation, ABS (-max_int - 1) cannot provide a correct
> positive value.  This replacement code does not apply ABS to the argument and
> is therefore immune to this problem.
>
> As well, replacement works on the argument from left to right, rather than
> right to left (the approach taken in the RR version).  Working from left to
> right in this way requires either:
>   - processing all 10 digits (speaking of 32 bit integers for the time being),
>     meaning worthless effort for every leading zero digit, or
>   - determining how many significant digits there are, which means some lookup
>     code (I believe this is faster but I haven't benchmarked it at this point)
>
> Having determined beforehand how many significant digits there are, we can
> allocate a working buffer of exactly the right length, which eliminates:
>   - the (expensive) digit-by-digit string concatenation approach used in the 
> RR
>     version
>   - the need to always ensure a long-enough fixed-length buffer should GNU 
> Algol
>     68 begin to support longer integers (128, 256, whatever)
>   - the need to trim a fixed-length buffer to the desired length once the
>     converted integer is in place
>
> Finally, working left to right
>   - eliminates the need to apply ABS to the number to be converted, as noted
>     previously, thereby eliminating the dependency on ABS
>   - replaces one (expensive) integer division with one (less expensive)
>     integer multiplication using a looked-up power of 10
>
> van Vliet's proposed whole and subwhole are more efficient than the RR 
> version,
> but still depend on ABS delivering a correct value.
>
> Included with this replacement proc whole is a test program to ensure that the
> correct results for the extreme values are produced, along with a set of
> randomly chosen other values distributed across the range.
>
> Signed-off-by: Chris Hermansen <[email protected]>
>
> libga68/ChangeLog
>
>       * standard.a68.in (Integer): New mode.
>       (whole_max_entry): New variable.
>       (whole_p10): Likewise.
>       (whole_stop_after): Likewise.
>       (whole_powers_of_10): Likewise.
>       (WHOLEDIGITS): New operator.
>       (whole): Rewrite.
>       (subwhole): Likewise.
>
> gcc/testsuite/ChangeLog
>
>       * algol68/execute/whole-1.a68: New test.
> ---
>  gcc/testsuite/algol68/execute/whole-1.a68 | 948 ++++++++++++++++++++++
>  libga68/standard.a68.in                   | 155 +++-
>  2 files changed, 1069 insertions(+), 34 deletions(-)
>  create mode 100644 gcc/testsuite/algol68/execute/whole-1.a68
>
> diff --git a/gcc/testsuite/algol68/execute/whole-1.a68 
> b/gcc/testsuite/algol68/execute/whole-1.a68
> new file mode 100644
> index 00000000000..ea9c34c9da0
> --- /dev/null
> +++ b/gcc/testsuite/algol68/execute/whole-1.a68
> @@ -0,0 +1,948 @@
> +begin
> +
> +      { RR standard proc whole replaced; test it }
> +
> +      short short int short_short_min_int = -short_short_max_int -
> +                                             short short 1;
> +      short int short_min_int = -short_max_int - short 1;
> +      int min_int = -max_int - short 1;
> +      long int long_min_int = -long_max_int - long 1;
> +      long long int long_long_min_int = -long_long_max_int -
> +                                         long long 1;
> +
> +      { testing short short int bits_width min and max values }
> +
> +      if short_short_bits_width = 8
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(short_short_min_int,0) = "-128");
> +           assert(whole(short short 0,0) = "0");
> +           assert(whole(short short 0,5) = "   +0");
> +           assert(whole(short short 0,-5) = "    0");
> +           assert(whole(short short 100,5) = " +100");
> +           assert(whole(-short short 100,5) = " -100");
> +           assert(whole(short short 100,-5) = "  100");
> +           assert(whole(-short short 100,-5) = " -100");
> +           assert(whole(short short 100,4) = "+100");
> +           assert(whole(-short short 100,4) = "-100");
> +           assert(whole(short short 100,3) = "***");
> +           assert(whole(-short short 100,3) = "***");
> +           assert(whole(short_short_max_int,0) = "127")
> +      elif short_short_bits_width = 16
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(short_short_min_int,0) = "-32768");
> +           assert(whole(short short 0,0) = "0");
> +           assert(whole(short short 0,5) = "   +0");
> +           assert(whole(short short 0,-5) = "    0");
> +           assert(whole(short short 100,5) = " +100");
> +           assert(whole(-short short 100,5) = " -100");
> +           assert(whole(short short 100,-5) = "  100");
> +           assert(whole(-short short 100,-5) = " -100");
> +           assert(whole(short short 100,4) = "+100");
> +           assert(whole(-short short 100,4) = "-100");
> +           assert(whole(short short 100,3) = "***");
> +           assert(whole(-short short 100,3) = "***");
> +           assert(whole(short_short_max_int,0) = "32767")
> +      elif short_short_bits_width = 32
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(short_short_min_int,0) = "-2147483648");
> +           assert(whole(short short 0,0) = "0");
> +           assert(whole(short short 0,5) = "   +0");
> +           assert(whole(short short 0,-5) = "    0");
> +           assert(whole(short short 100,5) = " +100");
> +           assert(whole(-short short 100,5) = " -100");
> +           assert(whole(short short 100,-5) = "  100");
> +           assert(whole(-short short 100,-5) = " -100");
> +           assert(whole(short short 100,4) = "+100");
> +           assert(whole(-short short 100,4) = "-100");
> +           assert(whole(short short 100,3) = "***");
> +           assert(whole(-short short 100,3) = "***");
> +           assert(whole(short_short_max_int,0) = "2147483647")
> +      elif short_short_bits_width = 64
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(short_short_min_int,0) = "-9223372036854775808");
> +           assert(whole(short short 0,0) = "0");
> +           assert(whole(short short 0,5) = "   +0");
> +           assert(whole(short short 0,-5) = "    0");
> +           assert(whole(short short 100,5) = " +100");
> +           assert(whole(-short short 100,5) = " -100");
> +           assert(whole(short short 100,-5) = "  100");
> +           assert(whole(-short short 100,-5) = " -100");
> +           assert(whole(short short 100,4) = "+100");
> +           assert(whole(-short short 100,4) = "-100");
> +           assert(whole(short short 100,3) = "***");
> +           assert(whole(-short short 100,3) = "***");
> +           assert(whole(short_short_max_int,0) = "9223372036854775807")
> +      elif short_short_bits_width = 128
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(short_short_min_int,0) = 
> "-170141183460469231731687303715884105728");
> +           assert(whole(short short 0,0) = "0");
> +           assert(whole(short short 0,5) = "   +0");
> +           assert(whole(short short 0,-5) = "    0");
> +           assert(whole(short short 100,5) = " +100");
> +           assert(whole(-short short 100,5) = " -100");
> +           assert(whole(short short 100,-5) = "  100");
> +           assert(whole(-short short 100,-5) = " -100");
> +           assert(whole(short short 100,4) = "+100");
> +           assert(whole(-short short 100,4) = "-100");
> +           assert(whole(short short 100,3) = "***");
> +           assert(whole(-short short 100,3) = "***");
> +           assert(whole(short_short_max_int,0) = 
> "170141183460469231731687303715884105727")
> +      fi;
> +
> +      { testing short int bits_width min and max values }
> +
> +      if short_bits_width = 8
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(short_min_int,0) = "-128");
> +           assert(whole(short 0,0) = "0");
> +           assert(whole(short 0,5) = "   +0");
> +           assert(whole(short 0,-5) = "    0");
> +           assert(whole(short 100,5) = " +100");
> +           assert(whole(-short 100,5) = " -100");
> +           assert(whole(short 100,-5) = "  100");
> +           assert(whole(-short 100,-5) = " -100");
> +           assert(whole(short 100,4) = "+100");
> +           assert(whole(-short 100,4) = "-100");
> +           assert(whole(short 100,3) = "***");
> +           assert(whole(-short 100,3) = "***");
> +           assert(whole(short_max_int,0) = "127")
> +      elif short_bits_width = 16
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(short_min_int,0) = "-32768");
> +           assert(whole(short 0,0) = "0");
> +           assert(whole(short 0,5) = "   +0");
> +           assert(whole(short 0,-5) = "    0");
> +           assert(whole(short 100,5) = " +100");
> +           assert(whole(-short 100,5) = " -100");
> +           assert(whole(short 100,-5) = "  100");
> +           assert(whole(-short 100,-5) = " -100");
> +           assert(whole(short 100,4) = "+100");
> +           assert(whole(-short 100,4) = "-100");
> +           assert(whole(short 100,3) = "***");
> +           assert(whole(-short 100,3) = "***");
> +           assert(whole(short_max_int,0) = "32767")
> +      elif short_bits_width = 32
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(short_min_int,0) = "-2147483648");
> +           assert(whole(short 0,0) = "0");
> +           assert(whole(short 0,5) = "   +0");
> +           assert(whole(short 0,-5) = "    0");
> +           assert(whole(short 100,5) = " +100");
> +           assert(whole(-short 100,5) = " -100");
> +           assert(whole(short 100,-5) = "  100");
> +           assert(whole(-short 100,-5) = " -100");
> +           assert(whole(short 100,4) = "+100");
> +           assert(whole(-short 100,4) = "-100");
> +           assert(whole(short 100,3) = "***");
> +           assert(whole(-short 100,3) = "***");
> +           assert(whole(short_max_int,0) = "2147483647")
> +      elif short_bits_width = 64
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(short_min_int,0) = "-9223372036854775808");
> +           assert(whole(short 0,0) = "0");
> +           assert(whole(short 0,5) = "   +0");
> +           assert(whole(short 0,-5) = "    0");
> +           assert(whole(short 100,5) = " +100");
> +           assert(whole(-short 100,5) = " -100");
> +           assert(whole(short 100,-5) = "  100");
> +           assert(whole(-short 100,-5) = " -100");
> +           assert(whole(short 100,4) = "+100");
> +           assert(whole(-short 100,4) = "-100");
> +           assert(whole(short 100,3) = "***");
> +           assert(whole(-short 100,3) = "***");
> +           assert(whole(short_max_int,0) = "9223372036854775807")
> +      elif short_bits_width = 128
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(short_min_int,0) = 
> "-170141183460469231731687303715884105728");
> +           assert(whole(short 0,0) = "0");
> +           assert(whole(short 0,5) = "   +0");
> +           assert(whole(short 0,-5) = "    0");
> +           assert(whole(short 100,5) = " +100");
> +           assert(whole(-short 100,5) = " -100");
> +           assert(whole(short 100,-5) = "  100");
> +           assert(whole(-short 100,-5) = " -100");
> +           assert(whole(short 100,4) = "+100");
> +           assert(whole(-short 100,4) = "-100");
> +           assert(whole(short 100,3) = "***");
> +           assert(whole(-short 100,3) = "***");
> +           assert(whole(short_max_int,0) = 
> "170141183460469231731687303715884105727")
> +      fi;
> +
> +      { testing int bits_width min and max values }
> +
> +      if bits_width = 8
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(min_int,0) = "-128");
> +           assert(whole(0,0) = "0");
> +           assert(whole(0,5) = "   +0");
> +           assert(whole(0,-5) = "    0");
> +           assert(whole(100,5) = " +100");
> +           assert(whole(-100,5) = " -100");
> +           assert(whole(100,-5) = "  100");
> +           assert(whole(-100,-5) = " -100");
> +           assert(whole(100,4) = "+100");
> +           assert(whole(-100,4) = "-100");
> +           assert(whole(100,3) = "***");
> +           assert(whole(-100,3) = "***");
> +           assert(whole(max_int,0) = "127")
> +      elif bits_width = 16
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(min_int,0) = "-32768");
> +           assert(whole(0,0) = "0");
> +           assert(whole(0,5) = "   +0");
> +           assert(whole(0,-5) = "    0");
> +           assert(whole(100,5) = " +100");
> +           assert(whole(-100,5) = " -100");
> +           assert(whole(100,-5) = "  100");
> +           assert(whole(-100,-5) = " -100");
> +           assert(whole(100,4) = "+100");
> +           assert(whole(-100,4) = "-100");
> +           assert(whole(100,3) = "***");
> +           assert(whole(-100,3) = "***");
> +           assert(whole(max_int,0) = "32767")
> +      elif bits_width = 32
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(min_int,0) = "-2147483648");
> +           assert(whole(0,0) = "0");
> +           assert(whole(0,5) = "   +0");
> +           assert(whole(0,-5) = "    0");
> +           assert(whole(100,5) = " +100");
> +           assert(whole(-100,5) = " -100");
> +           assert(whole(100,-5) = "  100");
> +           assert(whole(-100,-5) = " -100");
> +           assert(whole(100,4) = "+100");
> +           assert(whole(-100,4) = "-100");
> +           assert(whole(100,3) = "***");
> +           assert(whole(-100,3) = "***");
> +           assert(whole(max_int,0) = "2147483647")
> +      elif bits_width = 64
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(min_int,0) = "-9223372036854775808");
> +           assert(whole(0,0) = "0");
> +           assert(whole(0,5) = "   +0");
> +           assert(whole(0,-5) = "    0");
> +           assert(whole(100,5) = " +100");
> +           assert(whole(-100,5) = " -100");
> +           assert(whole(100,-5) = "  100");
> +           assert(whole(-100,-5) = " -100");
> +           assert(whole(100,4) = "+100");
> +           assert(whole(-100,4) = "-100");
> +           assert(whole(100,3) = "***");
> +           assert(whole(-100,3) = "***");
> +           assert(whole(max_int,0) = "9223372036854775807")
> +      elif bits_width = 128
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(min_int,0) = 
> "-170141183460469231731687303715884105728");
> +           assert(whole(0,0) = "0");
> +           assert(whole(0,5) = "   +0");
> +           assert(whole(0,-5) = "    0");
> +           assert(whole(100,5) = " +100");
> +           assert(whole(-100,5) = " -100");
> +           assert(whole(100,-5) = "  100");
> +           assert(whole(-100,-5) = " -100");
> +           assert(whole(100,4) = "+100");
> +           assert(whole(-100,4) = "-100");
> +           assert(whole(100,3) = "***");
> +           assert(whole(-100,3) = "***");
> +           assert(whole(max_int,0) = 
> "170141183460469231731687303715884105727")
> +      fi;
> +
> +      { testing long int bits_width min and max values }
> +
> +      if long_bits_width = 8
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(long_min_int,0) = "-128");
> +           assert(whole(long 0,0) = "0");
> +           assert(whole(long 0,5) = "   +0");
> +           assert(whole(long 0,-5) = "    0");
> +           assert(whole(long 100,5) = " +100");
> +           assert(whole(-long 100,5) = " -100");
> +           assert(whole(long 100,-5) = "  100");
> +           assert(whole(-long 100,-5) = " -100");
> +           assert(whole(long 100,4) = "+100");
> +           assert(whole(-long 100,4) = "-100");
> +           assert(whole(long 100,3) = "***");
> +           assert(whole(-long 100,3) = "***");
> +           assert(whole(long_max_int,0) = "127")
> +      elif long_bits_width = 16
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(long_min_int,0) = "-32768");
> +           assert(whole(long 0,0) = "0");
> +           assert(whole(long 0,5) = "   +0");
> +           assert(whole(long 0,-5) = "    0");
> +           assert(whole(long 100,5) = " +100");
> +           assert(whole(-long 100,5) = " -100");
> +           assert(whole(long 100,-5) = "  100");
> +           assert(whole(-long 100,-5) = " -100");
> +           assert(whole(long 100,4) = "+100");
> +           assert(whole(-long 100,4) = "-100");
> +           assert(whole(long 100,3) = "***");
> +           assert(whole(-long 100,3) = "***");
> +           assert(whole(long_max_int,0) = "32767")
> +      elif long_bits_width = 32
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(long_min_int,0) = "-2147483648");
> +           assert(whole(long 0,0) = "0");
> +           assert(whole(long 0,5) = "   +0");
> +           assert(whole(long 0,-5) = "    0");
> +           assert(whole(long 100,5) = " +100");
> +           assert(whole(-long 100,5) = " -100");
> +           assert(whole(long 100,-5) = "  100");
> +           assert(whole(-long 100,-5) = " -100");
> +           assert(whole(long 100,4) = "+100");
> +           assert(whole(-long 100,4) = "-100");
> +           assert(whole(long 100,3) = "***");
> +           assert(whole(-long 100,3) = "***");
> +           assert(whole(long_max_int,0) = "2147483647")
> +      elif long_bits_width = 64
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(long_min_int,0) = "-9223372036854775808");
> +           assert(whole(long 0,0) = "0");
> +           assert(whole(long 0,5) = "   +0");
> +           assert(whole(long 0,-5) = "    0");
> +           assert(whole(long 100,5) = " +100");
> +           assert(whole(-long 100,5) = " -100");
> +           assert(whole(long 100,-5) = "  100");
> +           assert(whole(-long 100,-5) = " -100");
> +           assert(whole(long 100,4) = "+100");
> +           assert(whole(-long 100,4) = "-100");
> +           assert(whole(long 100,3) = "***");
> +           assert(whole(-long 100,3) = "***");
> +           assert(whole(long_max_int,0) = "9223372036854775807")
> +      elif long_bits_width = 128
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(long_min_int,0) = 
> "-170141183460469231731687303715884105728");
> +           assert(whole(long 0,0) = "0");
> +           assert(whole(long 0,5) = "   +0");
> +           assert(whole(long 0,-5) = "    0");
> +           assert(whole(long 100,5) = " +100");
> +           assert(whole(-long 100,5) = " -100");
> +           assert(whole(long 100,-5) = "  100");
> +           assert(whole(-long 100,-5) = " -100");
> +           assert(whole(long 100,4) = "+100");
> +           assert(whole(-long 100,4) = "-100");
> +           assert(whole(long 100,3) = "***");
> +           assert(whole(-long 100,3) = "***");
> +           assert(whole(long_max_int,0) = 
> "170141183460469231731687303715884105727")
> +      fi;
> +
> +      { testing long long int bits_width min and max values }
> +
> +      if long_long_bits_width = 8
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(long_long_min_int,0) = "-128");
> +           assert(whole(long long 0,0) = "0");
> +           assert(whole(long long 0,5) = "   +0");
> +           assert(whole(long long 0,-5) = "    0");
> +           assert(whole(long long 100,5) = " +100");
> +           assert(whole(-long long 100,5) = " -100");
> +           assert(whole(long long 100,-5) = "  100");
> +           assert(whole(-long long 100,-5) = " -100");
> +           assert(whole(long long 100,4) = "+100");
> +           assert(whole(-long long 100,4) = "-100");
> +           assert(whole(long long 100,3) = "***");
> +           assert(whole(-long long 100,3) = "***");
> +           assert(whole(long_long_max_int,0) = "127")
> +      elif long_long_bits_width = 16
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(long_long_min_int,0) = "-32768");
> +           assert(whole(long long 0,0) = "0");
> +           assert(whole(long long 0,5) = "   +0");
> +           assert(whole(long long 0,-5) = "    0");
> +           assert(whole(long long 100,5) = " +100");
> +           assert(whole(-long long 100,5) = " -100");
> +           assert(whole(long long 100,-5) = "  100");
> +           assert(whole(-long long 100,-5) = " -100");
> +           assert(whole(long long 100,4) = "+100");
> +           assert(whole(-long long 100,4) = "-100");
> +           assert(whole(long long 100,3) = "***");
> +           assert(whole(-long long 100,3) = "***");
> +           assert(whole(long_long_max_int,0) = "32767")
> +      elif long_long_bits_width = 32
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(long_long_min_int,0) = "-2147483648");
> +           assert(whole(long long 0,0) = "0");
> +           assert(whole(long long 0,5) = "   +0");
> +           assert(whole(long long 0,-5) = "    0");
> +           assert(whole(long long 100,5) = " +100");
> +           assert(whole(-long long 100,5) = " -100");
> +           assert(whole(long long 100,-5) = "  100");
> +           assert(whole(-long long 100,-5) = " -100");
> +           assert(whole(long long 100,4) = "+100");
> +           assert(whole(-long long 100,4) = "-100");
> +           assert(whole(long long 100,3) = "***");
> +           assert(whole(-long long 100,3) = "***");
> +           assert(whole(long_long_max_int,0) = "2147483647")
> +      elif long_long_bits_width = 64
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(long_long_min_int,0) = "-9223372036854775808");
> +           assert(whole(long long 0,0) = "0");
> +           assert(whole(long long 0,5) = "   +0");
> +           assert(whole(long long 0,-5) = "    0");
> +           assert(whole(long long 100,5) = " +100");
> +           assert(whole(-long long 100,5) = " -100");
> +           assert(whole(long long 100,-5) = "  100");
> +           assert(whole(-long long 100,-5) = " -100");
> +           assert(whole(long long 100,4) = "+100");
> +           assert(whole(-long long 100,4) = "-100");
> +           assert(whole(long long 100,3) = "***");
> +           assert(whole(-long long 100,3) = "***");
> +           assert(whole(long_long_max_int,0) = "9223372036854775807")
> +      elif long_long_bits_width = 128
> +      then
> +           { this failed in orig RR whole which did not understand 2s comp }
> +           assert(whole(long_long_min_int,0) = 
> "-170141183460469231731687303715884105728");
> +           assert(whole(long long 0,0) = "0");
> +           assert(whole(long long 0,5) = "   +0");
> +           assert(whole(long long 0,-5) = "    0");
> +           assert(whole(long long 100,5) = " +100");
> +           assert(whole(-long long 100,5) = " -100");
> +           assert(whole(long long 100,-5) = "  100");
> +           assert(whole(-long long 100,-5) = " -100");
> +           assert(whole(long long 100,4) = "+100");
> +           assert(whole(-long long 100,4) = "-100");
> +           assert(whole(long long 100,3) = "***");
> +           assert(whole(-long long 100,3) = "***");
> +           assert(whole(long_long_max_int,0) = 
> "170141183460469231731687303715884105727")
> +      fi;
> +
> +      {testing random short short int values between -128 and 127}
> +
> +      assert(whole(short short 30,0) = "30");
> +      assert(whole(-short short 116,0) = "-116");
> +      assert(whole(short short 117,0) = "117");
> +      assert(whole(short short 44,0) = "44");
> +      assert(whole(short short 21,0) = "21");
> +      assert(whole(short short 20,0) = "20");
> +      assert(whole(short short 117,0) = "117");
> +      assert(whole(-short short 56,0) = "-56");
> +      assert(whole(short short 101,0) = "101");
> +      assert(whole(-short short 17,0) = "-17");
> +      assert(whole(-short short 125,0) = "-125");
> +      assert(whole(short short 53,0) = "53");
> +      assert(whole(-short short 45,0) = "-45");
> +      assert(whole(-short short 7,0) = "-7");
> +      assert(whole(short short 123,0) = "123");
> +      assert(whole(-short short 80,0) = "-80");
> +      assert(whole(-short short 64,0) = "-64");
> +      assert(whole(-short short 19,0) = "-19");
> +      assert(whole(-short short 95,0) = "-95");
> +      assert(whole(short short 91,0) = "91");
> +      assert(whole(-short short 47,0) = "-47");
> +      assert(whole(short short 61,0) = "61");
> +      assert(whole(-short short 29,0) = "-29");
> +      assert(whole(short short 44,0) = "44");
> +      assert(whole(-short short 46,0) = "-46");
> +      assert(whole(short short 37,0) = "37");
> +      assert(whole(short short 96,0) = "96");
> +      assert(whole(short short 41,0) = "41");
> +      assert(whole(-short short 41,0) = "-41");
> +      assert(whole(-short short 3,0) = "-3");
> +      assert(whole(short short 45,0) = "45");
> +      assert(whole(-short short 47,0) = "-47");
> +      assert(whole(-short short 92,0) = "-92");
> +      assert(whole(-short short 50,0) = "-50");
> +      assert(whole(short short 85,0) = "85");
> +      assert(whole(-short short 35,0) = "-35");
> +      assert(whole(short short 78,0) = "78");
> +      assert(whole(short short 40,0) = "40");
> +      assert(whole(short short 34,0) = "34");
> +      assert(whole(short short 40,0) = "40");
> +      assert(whole(short short 33,0) = "33");
> +      assert(whole(short short 50,0) = "50");
> +      assert(whole(-short short 102,0) = "-102");
> +      assert(whole(-short short 22,0) = "-22");
> +      assert(whole(-short short 60,0) = "-60");
> +      assert(whole(short short 2,0) = "2");
> +      assert(whole(short short 76,0) = "76");
> +      assert(whole(short short 44,0) = "44");
> +      assert(whole(-short short 101,0) = "-101");
> +      assert(whole(short short 47,0) = "47");
> +      assert(whole(short short 76,0) = "76");
> +      assert(whole(short short 119,0) = "119");
> +      assert(whole(short short 108,0) = "108");
> +      assert(whole(-short short 93,0) = "-93");
> +      assert(whole(short short 123,0) = "123");
> +      assert(whole(-short short 49,0) = "-49");
> +      assert(whole(short short 68,0) = "68");
> +      assert(whole(-short short 75,0) = "-75");
> +      assert(whole(short short 11,0) = "11");
> +      assert(whole(-short short 33,0) = "-33");
> +      assert(whole(-short short 101,0) = "-101");
> +      assert(whole(short short 118,0) = "118");
> +      assert(whole(short short 65,0) = "65");
> +      assert(whole(short short 117,0) = "117");
> +      assert(whole(-short short 74,0) = "-74");
> +      assert(whole(short short 74,0) = "74");
> +      assert(whole(short short 125,0) = "125");
> +      assert(whole(short short 48,0) = "48");
> +      assert(whole(short short 76,0) = "76");
> +      assert(whole(-short short 69,0) = "-69");
> +      assert(whole(short short 119,0) = "119");
> +      assert(whole(short short 118,0) = "118");
> +      assert(whole(short short 108,0) = "108");
> +      assert(whole(-short short 119,0) = "-119");
> +      assert(whole(-short short 54,0) = "-54");
> +      assert(whole(-short short 84,0) = "-84");
> +      assert(whole(-short short 99,0) = "-99");
> +      assert(whole(short short 5,0) = "5");
> +      assert(whole(-short short 74,0) = "-74");
> +      assert(whole(-short short 95,0) = "-95");
> +      assert(whole(short short 70,0) = "70");
> +      assert(whole(-short short 98,0) = "-98");
> +      assert(whole(short short 33,0) = "33");
> +      assert(whole(short short 74,0) = "74");
> +      assert(whole(short short 80,0) = "80");
> +      assert(whole(-short short 68,0) = "-68");
> +      assert(whole(-short short 33,0) = "-33");
> +      assert(whole(-short short 76,0) = "-76");
> +      assert(whole(short short 9,0) = "9");
> +      assert(whole(-short short 52,0) = "-52");
> +      assert(whole(short short 50,0) = "50");
> +      assert(whole(short short 53,0) = "53");
> +      assert(whole(short short 75,0) = "75");
> +      assert(whole(-short short 101,0) = "-101");
> +      assert(whole(-short short 108,0) = "-108");
> +      assert(whole(-short short 27,0) = "-27");
> +      assert(whole(-short short 35,0) = "-35");
> +      assert(whole(-short short 25,0) = "-25");
> +      assert(whole(-short short 77,0) = "-77");
> +      assert(whole(short short 76,0) = "76");
> +
> +      {testing random short int values between -32768 and 32767}
> +
> +      assert(whole(short 3503,0) = "3503");
> +      assert(whole(-short 8055,0) = "-8055");
> +      assert(whole(-short 3935,0) = "-3935");
> +      assert(whole(-short 10968,0) = "-10968");
> +      assert(whole(-short 8651,0) = "-8651");
> +      assert(whole(-short 4691,0) = "-4691");
> +      assert(whole(-short 12319,0) = "-12319");
> +      assert(whole(short 14058,0) = "14058");
> +      assert(whole(short 27310,0) = "27310");
> +      assert(whole(short 3028,0) = "3028");
> +      assert(whole(short 31112,0) = "31112");
> +      assert(whole(short 3805,0) = "3805");
> +      assert(whole(-short 28028,0) = "-28028");
> +      assert(whole(short 25727,0) = "25727");
> +      assert(whole(short 10603,0) = "10603");
> +      assert(whole(short 18697,0) = "18697");
> +      assert(whole(short 25636,0) = "25636");
> +      assert(whole(short 11014,0) = "11014");
> +      assert(whole(short 25754,0) = "25754");
> +      assert(whole(-short 4429,0) = "-4429");
> +      assert(whole(-short 6796,0) = "-6796");
> +      assert(whole(short 4387,0) = "4387");
> +      assert(whole(short 24536,0) = "24536");
> +      assert(whole(-short 18202,0) = "-18202");
> +      assert(whole(short 4251,0) = "4251");
> +      assert(whole(-short 923,0) = "-923");
> +      assert(whole(-short 25267,0) = "-25267");
> +      assert(whole(-short 6473,0) = "-6473");
> +      assert(whole(short 8072,0) = "8072");
> +      assert(whole(-short 1417,0) = "-1417");
> +      assert(whole(-short 9121,0) = "-9121");
> +      assert(whole(short 20304,0) = "20304");
> +      assert(whole(short 2206,0) = "2206");
> +      assert(whole(short 29555,0) = "29555");
> +      assert(whole(short 12764,0) = "12764");
> +      assert(whole(-short 18407,0) = "-18407");
> +      assert(whole(short 19032,0) = "19032");
> +      assert(whole(-short 24905,0) = "-24905");
> +      assert(whole(short 29130,0) = "29130");
> +      assert(whole(short 27021,0) = "27021");
> +      assert(whole(-short 5913,0) = "-5913");
> +      assert(whole(short 14052,0) = "14052");
> +      assert(whole(-short 11378,0) = "-11378");
> +      assert(whole(-short 607,0) = "-607");
> +      assert(whole(-short 19193,0) = "-19193");
> +      assert(whole(short 27668,0) = "27668");
> +      assert(whole(-short 11451,0) = "-11451");
> +      assert(whole(short 31411,0) = "31411");
> +      assert(whole(-short 11622,0) = "-11622");
> +      assert(whole(short 8028,0) = "8028");
> +      assert(whole(short 22654,0) = "22654");
> +      assert(whole(-short 24200,0) = "-24200");
> +      assert(whole(short 30148,0) = "30148");
> +      assert(whole(short 18724,0) = "18724");
> +      assert(whole(short 6318,0) = "6318");
> +      assert(whole(-short 31142,0) = "-31142");
> +      assert(whole(-short 5230,0) = "-5230");
> +      assert(whole(-short 17403,0) = "-17403");
> +      assert(whole(short 15107,0) = "15107");
> +      assert(whole(short 25146,0) = "25146");
> +      assert(whole(-short 8346,0) = "-8346");
> +      assert(whole(short 3862,0) = "3862");
> +      assert(whole(short 16005,0) = "16005");
> +      assert(whole(-short 22634,0) = "-22634");
> +      assert(whole(-short 9026,0) = "-9026");
> +      assert(whole(-short 11537,0) = "-11537");
> +      assert(whole(short 6811,0) = "6811");
> +      assert(whole(short 21603,0) = "21603");
> +      assert(whole(short 4103,0) = "4103");
> +      assert(whole(short 2240,0) = "2240");
> +      assert(whole(-short 23455,0) = "-23455");
> +      assert(whole(-short 30132,0) = "-30132");
> +      assert(whole(short 21132,0) = "21132");
> +      assert(whole(-short 10683,0) = "-10683");
> +      assert(whole(short 14190,0) = "14190");
> +      assert(whole(short 24575,0) = "24575");
> +      assert(whole(short 26048,0) = "26048");
> +      assert(whole(short 30585,0) = "30585");
> +      assert(whole(-short 28681,0) = "-28681");
> +      assert(whole(-short 3381,0) = "-3381");
> +      assert(whole(short 32360,0) = "32360");
> +      assert(whole(short 29261,0) = "29261");
> +      assert(whole(-short 2209,0) = "-2209");
> +      assert(whole(-short 16459,0) = "-16459");
> +      assert(whole(short 875,0) = "875");
> +      assert(whole(short 4037,0) = "4037");
> +      assert(whole(-short 22602,0) = "-22602");
> +      assert(whole(short 13502,0) = "13502");
> +      assert(whole(-short 27321,0) = "-27321");
> +      assert(whole(short 1598,0) = "1598");
> +      assert(whole(short 26282,0) = "26282");
> +      assert(whole(-short 31718,0) = "-31718");
> +      assert(whole(short 20597,0) = "20597");
> +      assert(whole(short 31435,0) = "31435");
> +      assert(whole(short 30701,0) = "30701");
> +      assert(whole(-short 17815,0) = "-17815");
> +      assert(whole(short 20800,0) = "20800");
> +      assert(whole(short 9693,0) = "9693");
> +      assert(whole(-short 19943,0) = "-19943");
> +      assert(whole(short 4186,0) = "4186");
> +
> +      {testing random int values between -2147483648 and 2147483647}
> +
> +      assert(whole(-403100802,0) = "-403100802");
> +      assert(whole(-1398207845,0) = "-1398207845");
> +      assert(whole(832199979,0) = "832199979");
> +      assert(whole(-314430426,0) = "-314430426");
> +      assert(whole(-1337423843,0) = "-1337423843");
> +      assert(whole(-1473243785,0) = "-1473243785");
> +      assert(whole(-1284464373,0) = "-1284464373");
> +      assert(whole(569381236,0) = "569381236");
> +      assert(whole(265320286,0) = "265320286");
> +      assert(whole(481489319,0) = "481489319");
> +      assert(whole(177155187,0) = "177155187");
> +      assert(whole(-1519375827,0) = "-1519375827");
> +      assert(whole(59347841,0) = "59347841");
> +      assert(whole(216383259,0) = "216383259");
> +      assert(whole(1204541248,0) = "1204541248");
> +      assert(whole(1352175722,0) = "1352175722");
> +      assert(whole(-1339082237,0) = "-1339082237");
> +      assert(whole(-1892481902,0) = "-1892481902");
> +      assert(whole(103359891,0) = "103359891");
> +      assert(whole(811383023,0) = "811383023");
> +      assert(whole(1028306761,0) = "1028306761");
> +      assert(whole(-437351215,0) = "-437351215");
> +      assert(whole(-150793982,0) = "-150793982");
> +      assert(whole(-1108543024,0) = "-1108543024");
> +      assert(whole(-11208696,0) = "-11208696");
> +      assert(whole(-835359094,0) = "-835359094");
> +      assert(whole(-1703726411,0) = "-1703726411");
> +      assert(whole(1349070474,0) = "1349070474");
> +      assert(whole(-699109453,0) = "-699109453");
> +      assert(whole(420661910,0) = "420661910");
> +      assert(whole(1224831744,0) = "1224831744");
> +      assert(whole(-706699415,0) = "-706699415");
> +      assert(whole(-677063649,0) = "-677063649");
> +      assert(whole(2058706762,0) = "2058706762");
> +      assert(whole(2078646591,0) = "2078646591");
> +      assert(whole(-1083083319,0) = "-1083083319");
> +      assert(whole(733572898,0) = "733572898");
> +      assert(whole(-1596639995,0) = "-1596639995");
> +      assert(whole(1179690802,0) = "1179690802");
> +      assert(whole(1022222166,0) = "1022222166");
> +      assert(whole(907520320,0) = "907520320");
> +      assert(whole(-2020974298,0) = "-2020974298");
> +      assert(whole(630153429,0) = "630153429");
> +      assert(whole(-1437607207,0) = "-1437607207");
> +      assert(whole(-70179507,0) = "-70179507");
> +      assert(whole(172108858,0) = "172108858");
> +      assert(whole(-83462577,0) = "-83462577");
> +      assert(whole(1220711557,0) = "1220711557");
> +      assert(whole(-1103245389,0) = "-1103245389");
> +      assert(whole(-1147801577,0) = "-1147801577");
> +      assert(whole(1464141854,0) = "1464141854");
> +      assert(whole(809294007,0) = "809294007");
> +      assert(whole(-356634754,0) = "-356634754");
> +      assert(whole(-149999631,0) = "-149999631");
> +      assert(whole(-104783485,0) = "-104783485");
> +      assert(whole(-2067391664,0) = "-2067391664");
> +      assert(whole(902412219,0) = "902412219");
> +      assert(whole(877713857,0) = "877713857");
> +      assert(whole(-1779716391,0) = "-1779716391");
> +      assert(whole(-402988036,0) = "-402988036");
> +      assert(whole(25627773,0) = "25627773");
> +      assert(whole(-1677204638,0) = "-1677204638");
> +      assert(whole(-692742416,0) = "-692742416");
> +      assert(whole(795383882,0) = "795383882");
> +      assert(whole(95990551,0) = "95990551");
> +      assert(whole(-543093303,0) = "-543093303");
> +      assert(whole(-1513903728,0) = "-1513903728");
> +      assert(whole(1489666329,0) = "1489666329");
> +      assert(whole(750814966,0) = "750814966");
> +      assert(whole(1154079971,0) = "1154079971");
> +      assert(whole(-1429750049,0) = "-1429750049");
> +      assert(whole(-1152819244,0) = "-1152819244");
> +      assert(whole(-1124298499,0) = "-1124298499");
> +      assert(whole(50261656,0) = "50261656");
> +      assert(whole(316126787,0) = "316126787");
> +      assert(whole(2117873709,0) = "2117873709");
> +      assert(whole(-1144808693,0) = "-1144808693");
> +      assert(whole(-841230705,0) = "-841230705");
> +      assert(whole(-1816490862,0) = "-1816490862");
> +      assert(whole(1311093725,0) = "1311093725");
> +      assert(whole(-1916801894,0) = "-1916801894");
> +      assert(whole(-1293400369,0) = "-1293400369");
> +      assert(whole(-1385414947,0) = "-1385414947");
> +      assert(whole(1271329139,0) = "1271329139");
> +      assert(whole(-512302845,0) = "-512302845");
> +      assert(whole(654388103,0) = "654388103");
> +      assert(whole(829132954,0) = "829132954");
> +      assert(whole(1151221068,0) = "1151221068");
> +      assert(whole(-835494487,0) = "-835494487");
> +      assert(whole(1588422425,0) = "1588422425");
> +      assert(whole(109289160,0) = "109289160");
> +      assert(whole(607092656,0) = "607092656");
> +      assert(whole(950512894,0) = "950512894");
> +      assert(whole(-638343067,0) = "-638343067");
> +      assert(whole(706750001,0) = "706750001");
> +      assert(whole(-1412829813,0) = "-1412829813");
> +      assert(whole(2029245474,0) = "2029245474");
> +      assert(whole(1115959105,0) = "1115959105");
> +      assert(whole(-143412736,0) = "-143412736");
> +      assert(whole(1623878673,0) = "1623878673");
> +
> +      {testing random long int values between -9223372036854775808 and 
> 9223372036854775807}
> +
> +      assert(whole(long 2000751727886147751,0) = "2000751727886147751");
> +      assert(whole(-long 8209586255195506053,0) = "-8209586255195506053");
> +      assert(whole(-long 5211436987189768727,0) = "-5211436987189768727");
> +      assert(whole(long 3481841343391796357,0) = "3481841343391796357");
> +      assert(whole(long 690960258437165470,0) = "690960258437165470");
> +      assert(whole(long 2523029388282391222,0) = "2523029388282391222");
> +      assert(whole(-long 5041965162172324571,0) = "-5041965162172324571");
> +      assert(whole(long 5806250066822741155,0) = "5806250066822741155");
> +      assert(whole(long 7434918958482692467,0) = "7434918958482692467");
> +      assert(whole(-long 6405176401886229763,0) = "-6405176401886229763");
> +      assert(whole(long 6889530937260973061,0) = "6889530937260973061");
> +      assert(whole(-long 8718137720999335718,0) = "-8718137720999335718");
> +      assert(whole(-long 6116019823292316302,0) = "-6116019823292316302");
> +      assert(whole(long 7176063991220177363,0) = "7176063991220177363");
> +      assert(whole(long 5624177737173859667,0) = "5624177737173859667");
> +      assert(whole(-long 6728618139065383615,0) = "-6728618139065383615");
> +      assert(whole(-long 3637134344574050688,0) = "-3637134344574050688");
> +      assert(whole(-long 4187265742129456341,0) = "-4187265742129456341");
> +      assert(whole(-long 1054988900287603981,0) = "-1054988900287603981");
> +      assert(whole(-long 3589531398842171382,0) = "-3589531398842171382");
> +      assert(whole(-long 3837722621741715835,0) = "-3837722621741715835");
> +      assert(whole(-long 2277618771197657778,0) = "-2277618771197657778");
> +      assert(whole(-long 586259625295916749,0) = "-586259625295916749");
> +      assert(whole(long 2486181354071841326,0) = "2486181354071841326");
> +      assert(whole(long 2671656715190564215,0) = "2671656715190564215");
> +      assert(whole(-long 1602965929202284825,0) = "-1602965929202284825");
> +      assert(whole(-long 3078680151464021197,0) = "-3078680151464021197");
> +      assert(whole(long 1604368937738455413,0) = "1604368937738455413");
> +      assert(whole(long 7033461762810777446,0) = "7033461762810777446");
> +      assert(whole(-long 4915965037828090348,0) = "-4915965037828090348");
> +      assert(whole(long 4663442186490351114,0) = "4663442186490351114");
> +      assert(whole(long 320611373827802418,0) = "320611373827802418");
> +      assert(whole(-long 8644625706382975770,0) = "-8644625706382975770");
> +      assert(whole(long 6112352955252261286,0) = "6112352955252261286");
> +      assert(whole(-long 5411281901650093896,0) = "-5411281901650093896");
> +      assert(whole(-long 5886311757456009558,0) = "-5886311757456009558");
> +      assert(whole(-long 6370825334282316695,0) = "-6370825334282316695");
> +      assert(whole(long 6260133907146216724,0) = "6260133907146216724");
> +      assert(whole(-long 1129686235629706672,0) = "-1129686235629706672");
> +      assert(whole(-long 5196761836215158365,0) = "-5196761836215158365");
> +      assert(whole(long 5696076799083177842,0) = "5696076799083177842");
> +      assert(whole(-long 8715973978022801493,0) = "-8715973978022801493");
> +      assert(whole(long 8684010893599161940,0) = "8684010893599161940");
> +      assert(whole(long 2889305961487859277,0) = "2889305961487859277");
> +      assert(whole(long 1641288009733302553,0) = "1641288009733302553");
> +      assert(whole(long 5886925832571802079,0) = "5886925832571802079");
> +      assert(whole(long 1326178806201890792,0) = "1326178806201890792");
> +      assert(whole(-long 1337196939196106016,0) = "-1337196939196106016");
> +      assert(whole(long 1500806829693949175,0) = "1500806829693949175");
> +      assert(whole(long 4842805353620492100,0) = "4842805353620492100");
> +      assert(whole(long 5309308043867904646,0) = "5309308043867904646");
> +      assert(whole(long 6209415249714271698,0) = "6209415249714271698");
> +      assert(whole(long 7429550362116828006,0) = "7429550362116828006");
> +      assert(whole(-long 8204062681865459722,0) = "-8204062681865459722");
> +      assert(whole(-long 1349569390017616723,0) = "-1349569390017616723");
> +      assert(whole(-long 7558566826316437342,0) = "-7558566826316437342");
> +      assert(whole(-long 5789923554031087092,0) = "-5789923554031087092");
> +      assert(whole(-long 8639236710259188044,0) = "-8639236710259188044");
> +      assert(whole(-long 7938133470641140372,0) = "-7938133470641140372");
> +      assert(whole(long 5255178156720403551,0) = "5255178156720403551");
> +      assert(whole(-long 7863497050998961999,0) = "-7863497050998961999");
> +      assert(whole(long 3249912638364174576,0) = "3249912638364174576");
> +      assert(whole(long 891317806599313109,0) = "891317806599313109");
> +      assert(whole(-long 1932320484056494305,0) = "-1932320484056494305");
> +      assert(whole(long 4176622234804239805,0) = "4176622234804239805");
> +      assert(whole(-long 7385765929299147406,0) = "-7385765929299147406");
> +      assert(whole(-long 444484872487926785,0) = "-444484872487926785");
> +      assert(whole(long 5667607892232184451,0) = "5667607892232184451");
> +      assert(whole(-long 3364838895669718223,0) = "-3364838895669718223");
> +      assert(whole(-long 8106160154562537501,0) = "-8106160154562537501");
> +      assert(whole(long 4024278926357670361,0) = "4024278926357670361");
> +      assert(whole(long 5292772559442875975,0) = "5292772559442875975");
> +      assert(whole(long 932190487089499511,0) = "932190487089499511");
> +      assert(whole(-long 775367273302046489,0) = "-775367273302046489");
> +      assert(whole(long 7602143321460885477,0) = "7602143321460885477");
> +      assert(whole(-long 317782206184848746,0) = "-317782206184848746");
> +      assert(whole(-long 7123753982383649729,0) = "-7123753982383649729");
> +      assert(whole(long 6151697697526307270,0) = "6151697697526307270");
> +      assert(whole(long 8512358833708185563,0) = "8512358833708185563");
> +      assert(whole(long 8297632004576639885,0) = "8297632004576639885");
> +      assert(whole(-long 4682707546061768077,0) = "-4682707546061768077");
> +      assert(whole(long 6795151789649607406,0) = "6795151789649607406");
> +      assert(whole(long 738258458205097333,0) = "738258458205097333");
> +      assert(whole(long 2306763718473047774,0) = "2306763718473047774");
> +      assert(whole(-long 5823745590182419592,0) = "-5823745590182419592");
> +      assert(whole(long 7127104180341210031,0) = "7127104180341210031");
> +      assert(whole(long 1474577461515786934,0) = "1474577461515786934");
> +      assert(whole(long 6132347178447808514,0) = "6132347178447808514");
> +      assert(whole(long 3349768669013398040,0) = "3349768669013398040");
> +      assert(whole(-long 3035856852955187810,0) = "-3035856852955187810");
> +      assert(whole(long 5083565630079627188,0) = "5083565630079627188");
> +      assert(whole(-long 3726588518613842730,0) = "-3726588518613842730");
> +      assert(whole(long 61062208449684700,0) = "61062208449684700");
> +      assert(whole(-long 3132014502905353186,0) = "-3132014502905353186");
> +      assert(whole(-long 7459252962100862666,0) = "-7459252962100862666");
> +      assert(whole(long 2358002016735975854,0) = "2358002016735975854");
> +      assert(whole(long 8002507807388287789,0) = "8002507807388287789");
> +      assert(whole(-long 7251148814464051407,0) = "-7251148814464051407");
> +      assert(whole(-long 4136787452602721926,0) = "-4136787452602721926");
> +      assert(whole(long 5901836429512669496,0) = "5901836429512669496");
> +
> +      {testing random long long int values between -9223372036854775808 and 
> 9223372036854775807}
> +
> +      assert(whole(-long long 5153365255204034573,0) = 
> "-5153365255204034573");
> +      assert(whole(-long long 776331665639608338,0) = "-776331665639608338");
> +      assert(whole(long long 4335291442932356813,0) = "4335291442932356813");
> +      assert(whole(long long 2732439320080222074,0) = "2732439320080222074");
> +      assert(whole(long long 1768242404645377449,0) = "1768242404645377449");
> +      assert(whole(long long 3491979373335892872,0) = "3491979373335892872");
> +      assert(whole(long long 3401721067457720638,0) = "3401721067457720638");
> +      assert(whole(-long long 4702592594299544162,0) = 
> "-4702592594299544162");
> +      assert(whole(long long 5425686184027932994,0) = "5425686184027932994");
> +      assert(whole(long long 4411264892186246525,0) = "4411264892186246525");
> +      assert(whole(long long 7273215159638578572,0) = "7273215159638578572");
> +      assert(whole(-long long 4582902216034311259,0) = 
> "-4582902216034311259");
> +      assert(whole(long long 2370808784495729510,0) = "2370808784495729510");
> +      assert(whole(long long 2665216817640841338,0) = "2665216817640841338");
> +      assert(whole(-long long 7126531842578155781,0) = 
> "-7126531842578155781");
> +      assert(whole(long long 8371345850105992435,0) = "8371345850105992435");
> +      assert(whole(long long 7998304148609064210,0) = "7998304148609064210");
> +      assert(whole(-long long 8163815673092574454,0) = 
> "-8163815673092574454");
> +      assert(whole(-long long 2001232235480029851,0) = 
> "-2001232235480029851");
> +      assert(whole(long long 471916789433704337,0) = "471916789433704337");
> +      assert(whole(-long long 8154300678198609006,0) = 
> "-8154300678198609006");
> +      assert(whole(long long 5290522198727677086,0) = "5290522198727677086");
> +      assert(whole(long long 147114572508738885,0) = "147114572508738885");
> +      assert(whole(long long 391059118537886777,0) = "391059118537886777");
> +      assert(whole(-long long 2563390679566777062,0) = 
> "-2563390679566777062");
> +      assert(whole(-long long 3994175603525616854,0) = 
> "-3994175603525616854");
> +      assert(whole(long long 496078728018586997,0) = "496078728018586997");
> +      assert(whole(-long long 1734200432626566410,0) = 
> "-1734200432626566410");
> +      assert(whole(long long 4164881865254444522,0) = "4164881865254444522");
> +      assert(whole(-long long 6790775709925543313,0) = 
> "-6790775709925543313");
> +      assert(whole(-long long 4304666423172008750,0) = 
> "-4304666423172008750");
> +      assert(whole(-long long 8954238941095795869,0) = 
> "-8954238941095795869");
> +      assert(whole(-long long 8337663766260128866,0) = 
> "-8337663766260128866");
> +      assert(whole(long long 949256083175133995,0) = "949256083175133995");
> +      assert(whole(long long 6009023131756010877,0) = "6009023131756010877");
> +      assert(whole(-long long 7639526581869384668,0) = 
> "-7639526581869384668");
> +      assert(whole(long long 4388452973916673268,0) = "4388452973916673268");
> +      assert(whole(long long 7746043457852702610,0) = "7746043457852702610");
> +      assert(whole(-long long 8149977344360527938,0) = 
> "-8149977344360527938");
> +      assert(whole(long long 4448251315532658327,0) = "4448251315532658327");
> +      assert(whole(-long long 5135188612278663070,0) = 
> "-5135188612278663070");
> +      assert(whole(-long long 4797046808744719489,0) = 
> "-4797046808744719489");
> +      assert(whole(-long long 7750107695213844098,0) = 
> "-7750107695213844098");
> +      assert(whole(-long long 9219778313125401306,0) = 
> "-9219778313125401306");
> +      assert(whole(-long long 1190972656406746645,0) = 
> "-1190972656406746645");
> +      assert(whole(long long 3005982242222302615,0) = "3005982242222302615");
> +      assert(whole(long long 5301831249279847096,0) = "5301831249279847096");
> +      assert(whole(-long long 4141421373107683641,0) = 
> "-4141421373107683641");
> +      assert(whole(-long long 2816200745283394605,0) = 
> "-2816200745283394605");
> +      assert(whole(long long 8778726055828346793,0) = "8778726055828346793");
> +      assert(whole(-long long 3206713470320379742,0) = 
> "-3206713470320379742");
> +      assert(whole(long long 6520735421301069455,0) = "6520735421301069455");
> +      assert(whole(-long long 1396469569049042334,0) = 
> "-1396469569049042334");
> +      assert(whole(-long long 7269115740536375803,0) = 
> "-7269115740536375803");
> +      assert(whole(long long 2160351365460443683,0) = "2160351365460443683");
> +      assert(whole(-long long 1316276740473262316,0) = 
> "-1316276740473262316");
> +      assert(whole(-long long 6373838130217854388,0) = 
> "-6373838130217854388");
> +      assert(whole(long long 2562447621837271432,0) = "2562447621837271432");
> +      assert(whole(long long 6293181472454460046,0) = "6293181472454460046");
> +      assert(whole(long long 1493945378371622544,0) = "1493945378371622544");
> +      assert(whole(long long 778478089466296119,0) = "778478089466296119");
> +      assert(whole(-long long 4316093485526552007,0) = 
> "-4316093485526552007");
> +      assert(whole(long long 8387342276262215434,0) = "8387342276262215434");
> +      assert(whole(-long long 4210385934411236002,0) = 
> "-4210385934411236002");
> +      assert(whole(long long 2050638476872507298,0) = "2050638476872507298");
> +      assert(whole(-long long 2629034594500208575,0) = 
> "-2629034594500208575");
> +      assert(whole(-long long 6150848349519253844,0) = 
> "-6150848349519253844");
> +      assert(whole(-long long 2429229408439176088,0) = 
> "-2429229408439176088");
> +      assert(whole(long long 7233363348512259980,0) = "7233363348512259980");
> +      assert(whole(-long long 1957488695786359316,0) = 
> "-1957488695786359316");
> +      assert(whole(-long long 700045719090107674,0) = "-700045719090107674");
> +      assert(whole(-long long 6997295081834142303,0) = 
> "-6997295081834142303");
> +      assert(whole(long long 8156109753921647445,0) = "8156109753921647445");
> +      assert(whole(long long 171352807657823264,0) = "171352807657823264");
> +      assert(whole(-long long 7671362793928665837,0) = 
> "-7671362793928665837");
> +      assert(whole(long long 3088638805156752224,0) = "3088638805156752224");
> +      assert(whole(long long 5995155998824845526,0) = "5995155998824845526");
> +      assert(whole(long long 8884072709527103591,0) = "8884072709527103591");
> +      assert(whole(-long long 8298663658687149659,0) = 
> "-8298663658687149659");
> +      assert(whole(long long 740559831498251244,0) = "740559831498251244");
> +      assert(whole(long long 2271019220479614726,0) = "2271019220479614726");
> +      assert(whole(long long 4229259096603590455,0) = "4229259096603590455");
> +      assert(whole(long long 2462690719565923594,0) = "2462690719565923594");
> +      assert(whole(-long long 6238586968253522222,0) = 
> "-6238586968253522222");
> +      assert(whole(long long 7934547824919629378,0) = "7934547824919629378");
> +      assert(whole(long long 5501149081621417400,0) = "5501149081621417400");
> +      assert(whole(long long 6956366543890594417,0) = "6956366543890594417");
> +      assert(whole(-long long 2877320621245302229,0) = 
> "-2877320621245302229");
> +      assert(whole(-long long 2447701309465336788,0) = 
> "-2447701309465336788");
> +      assert(whole(long long 7200122643244394888,0) = "7200122643244394888");
> +      assert(whole(-long long 7472639175537233839,0) = 
> "-7472639175537233839");
> +      assert(whole(long long 5419631634715727098,0) = "5419631634715727098");
> +      assert(whole(-long long 8027915039718311439,0) = 
> "-8027915039718311439");
> +      assert(whole(long long 6255157334205441133,0) = "6255157334205441133");
> +      assert(whole(-long long 2611616147385198047,0) = 
> "-2611616147385198047");
> +      assert(whole(long long 1906099468310042628,0) = "1906099468310042628");
> +      assert(whole(-long long 6290331456803530992,0) = 
> "-6290331456803530992");
> +      assert(whole(-long long 6953956488428111867,0) = 
> "-6953956488428111867");
> +      assert(whole(-long long 9097046594145938000,0) = 
> "-9097046594145938000");
> +      assert(whole(long long 4818193871933837971,0) = "4818193871933837971")
> +
> +end
> diff --git a/libga68/standard.a68.in b/libga68/standard.a68.in
> index 5246679fa9f..5ecb36b4a37 100644
> --- a/libga68/standard.a68.in
> +++ b/libga68/standard.a68.in
> @@ -58,28 +58,95 @@ def
>                       {reti {,}}
>                    );
>  
> +    { The definition of mode Integer used by both the RR subwhole and this 
> one.  }
> +    
> +    mode Integer = union (
> +                      {iter L {long long } {long } {} {short } {short short 
> }}
> +                      {L}int
> +                      {reti {,}}
> +                   );
> +    
> +    { The whole_powers_of_10 row is used to look up the appropriate power of 
> 10 for
> +      each integer division required to select the leading in the conversion
> +      process, for each integer multiplication to eliminate the leading 
> digit,
> +      and in the lookup operator WHOLEDIGITS to determine the number of 
> digits in
> +      the integer to be converted.  }
> +    
> +    int whole_max_entry := 1;
> +    long long int whole_p10 := long long 1;
> +    long long int whole_stop_after = long_long_max_int % long long 10;
> +    while whole_p10 < whole_stop_after
> +    do
> +       whole_p10 *:= long long 10;
> +       whole_max_entry +:= 1
> +    od;
> +    heap [1:whole_max_entry]long long int whole_powers_of_10;
> +    while whole_max_entry > 0
> +    do
> +       whole_powers_of_10[whole_max_entry] := whole_p10;
> +       whole_p10 %:= long long 10;
> +       whole_max_entry -:= 1
> +    od;
> +    
> +    { The WHOLEDIGITS operator is used to determine the number of decimal 
> digits in a
> +      number.  We convert the operand to long long and make it negative if
> +      necessary, to allow for twos-complement minimum (negative) integer.  }
> +    
> +    op WHOLEDIGITS = (Integer number) int:
> +    begin
> +          long long int work =
> +             case number in
> +                {iter L {long long } {long } {} {short } {short short }}
> +                {iter K {} {LENG } {LENG LENG } {LENG LENG LENG } {LENG LENG 
> LENG LENG }}
> +                ({L}int x):
> +                   {K}(x > {L} 0 | -x | x)
> +                {reti {,}}
> +             esac;
> +          int num_digits := 1;
> +          for i from (LWB whole_powers_of_10) + 1 to UPB whole_powers_of_10
> +              while work <= -whole_powers_of_10[i]
> +          do num_digits +:= 1 od;
> +          num_digits
> +    end { WHOLEDIGITS };
> +    
> +    { proc whole checks for a too-small width, returning a string of the 
> error
> +      character if so; it left-pads the result with blanks as necessary and 
> the
> +      sign as necessary; and it relies on subwhole to do the actual digit
> +      conversion.  The [] result returned is either exactly the number of 
> chars
> +      needed (width = 0) to hold the converted integer and negative sign if 
> < 0
> +      or width characters (width ≠ 0).  }
> +    
> +    
>      pub proc whole = (Number v, int width) string:
>         case v in
> -          {iter L  {short short}  {short}  {} {long}  {long long}}
> -          {iter L_ {short_short_} {short_} {} {long_} {long_long_}}
> -          ({L} int x):
> -             (int length := ABS width - (x < {L} 0 OR width > 0 | 1 | 0),
> -                            {L} int n := ABS x;
> -              if width = 0
> -              then {L} int m := n; length := 0;
> -                   while m %:= {L} 10; length +:= 1; m /= {L} 0
> -                   do ~ od
> -              fi;
> -              string s := subwhole (n, length);
> -              if length = 0 OR char_in_string (errorchar, loc int, s)
> -              then ABS width * errorchar
> -              else (x < {L} 0 | "-" |: width > 0 | "+" | "") +=: s;
> -                   (width /= 0 | (ABS width - UPB s) * " " +=: s);
> -                   s
> -              fi),
> -          ({L} real x): fixed (x, width, 0)
> +          {iter L {long long } {long } {} {short } {short short }}
> +          ({L}int x):
> +             if int digits_required = WHOLEDIGITS x;
> +                bool negative = x < {L}0;
> +                int signs_required = (negative OR width > 0 | 1 | 0);
> +                int chars_required = signs_required + digits_required;
> +                int chars_available = (width = 0 | chars_required | ABS 
> width);
> +                chars_available < chars_required
> +             then chars_available * "*"
> +             else [1:chars_available]char buffer;
> +                  int spaces_required = chars_available - chars_required;
> +                  int buf_ch := 1;
> +                  while buf_ch <= spaces_required
> +                  do buffer[buf_ch] := " ";
> +                     buf_ch +:= 1
> +                  od;
> +                  if signs_required > 0
> +                  then buffer[buf_ch] := (negative | "-" | "+");
> +                       buf_ch +:= 1
> +                  fi;
> +                  subwhole(x, buffer, buf_ch);
> +                  buffer
> +             fi
>            {reti {,}}
> -       esac;
> +       out
> +          fixed(v, width, 0)
> +       esac { whole };
> +
>  
>      pub proc fixed = (Number v, int width, after) string:
>         case v in
> @@ -137,22 +204,42 @@ def
>             {reti {,}}
>          esac;
>  
> -    { Returns a string of maximum length `width' containing a decimal
> -      representation of the positive integer `v'. }
> -
> -    proc subwhole = (Number v, int width) string:
> -       case v in
> -          {iter L {short short} {short} {} {long}    {long long}}
> -          {iter S {LENG LENG}   {LENG}  {} {SHORTEN} {SHORTEN SHORTEN}}
> -          ({L} int x):
> -             begin string s, {L} int n := x;
> -                   while dig_char ({S} (n MOD {L} 10)) +=: s;
> -                         n %:= {L} 10; n /= {L} 0
> -                   do ~ od;
> -                   (UPB s > width | width * errorchar | s)
> -             end
> +    { The RR proc subwhole looks like
> +    
> +      proc ℵ₀ subwhole = (number v, int width) string: { implementation };
> +    
> +      We deviate from that design below.  This means that, should someone 
> copy
> +      proc putf from the RR, they must recognize that the subwhole mentioned
> +      there is no longer defined here, and make adjustments.
> +    
> +      I considered calling this subwhole something else (whole_do_conv for 
> example)
> +      but that would mean anyone else calling subwhole hoping to get the new
> +      version would silently get the old subwhole instead.
> +    
> +      This subwhole converts digit by digit from left to right.  It relies 
> on the
> +      caller having padded out the buffer with spaces and sign as required 
> and
> +      begins filling digits starting at the value passed in buf_ch.  The 
> final
> +      []char array and final value of buf_ch are returned.  }
> +    
> +    proc subwhole = (Integer v, ref []char buffer, ref int buf_ch) void:
> +       case int char_zero = ABS "0"; v in
> +          {iter L {long long } {long } {} {short } {short short }}
> +          {iter K {LENG LENG } {LENG } {} {SHORTEN } {SHORTEN SHORTEN }}
> +          {iter S {SHORTEN SHORTEN } {SHORTEN } {} {LENG } {LENG LENG }}k
> +          {iter T {} {SHORTEN } {SHORTEN SHORTEN } {SHORTEN SHORTEN SHORTEN 
> } {SHORTEN SHORTEN SHORTEN SHORTEN }}
> +          ({L}int number_to_convert):
> +          begin {L}int work := number_to_convert;
> +                while buf_ch <= UPB buffer
> +                do int digit_number = UPB buffer - buf_ch + 1;
> +                   {L}int p10 = {T}whole_powers_of_10[digit_number];
> +                   int digit = {S} (work % p10);
> +                   buffer[buf_ch] := REPR (ABS digit + char_zero);
> +                   buf_ch +:= 1;
> +                   work -:= {K}digit * p10
> +                od
> +          end
>            {reti {,}}
> -       esac;
> +       esac { subwhole };
>  
>      { Returns a string of maximum length `width' containing a rounded
>        decimal representation of the positive real number `v'; if

Reply via email to