curiousdannii-testing / inform7-imported-bugs

0 stars 0 forks source link

[I7-2045] [Mantis 2082] Trying to print the minimum integer in words instead prints nothing at all #39

Closed curiousdannii-testing closed 2 years ago

curiousdannii-testing commented 2 years ago

Reported by : Spike

Description :

The minimum integer allowed by Glulx is -2147483648. Attempting to print that number in words instead prints nothing at all. However, printing -2147483647 or 2147483647 (the maximum integer allowed by Glulx) in words works just fine.

Steps to reproduce :

VERYSMALL is always -2147483647.
minimum-testing is an action out of world.  Understand "minimum" as minimum-testing.
Carry out minimum-testing:
   let newnumber be VERYSMALL;
   say "The minimum integer in Glulx is almost [newnumber], which is [newnumber in words].[paragraph break]";
   let newnumber be newnumber - 1;
   say "The minimum integer in Glulx actually is [newnumber], which is [newnumber in words].[paragraph break]";
   let newnumber be newnumber - 1;
   say "But the maximum integer in Glulx is [newnumber], which is [newnumber in words].[paragraph break]".

Additional information :

The problem appears to be in the I6 library (function LanguageNumber in file english.h). The routine for printing a number N in words begins by checking whether N is negative; if it is, it prints "minus", and replaces N with -N. The remainder of the routine then assumes that N is positive. Unfortunately, if N is the minimum integer, then -N = N, so that assumption doesn't work very well.

From this thread on intfiction.org: https://www.intfiction.org/forum/viewtopic.php?f=7&t=26948

imported from: [Mantis 2082] Trying to print the minimum integer in words instead prints nothing at all
  • status: Closed
  • resolution: Resolved
  • resolved: 2022-04-10T04:25:46+10:00
  • imported: 2022/01/10
curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by zarf :
Confirmed.

The simplest and, I suppose, only solution I see is to special-case that value. Same as "zero" is special-cased. Only with a much longer hard-coded string.

curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by zarf :
Now that I think about it, it would be slightly more elegant to print "minus two billion", set n to 147483648, and then goto the appropriate line to continue printing in the usual way.

Or just print "minus zero". I'd be fine with that. I can't speak for other IF authors.

curiousdannii-testing commented 2 years ago

61eedb62875fc10070240916:

Fixed via this commit:

https://github.com/ganelson/inform/commit/e36977909860e64d0130f8147cecaf9c0313dcfe

Comment by Graham Nelson:
For both 16 and 32-bit word sizes; it's not a Glulx-only problem. See test cases BIP-Say and BIP-Say-G.