Skip to content

Instantly share code, notes, and snippets.

@wvdschel
Created February 13, 2015 08:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wvdschel/ee1aa2d979ef1974de31 to your computer and use it in GitHub Desktop.
Minimum integer bug
module: main
define function main() => ()
format-out("In main()\n");
let val :: <integer> = floor/($minimum-integer + 1, 10);
format-out("(min+1)/10: ");
format-out(integer-to-string(val));
format-out("\n");
iterate invert ( div = 2 ^ 33 )
format-out(integer-to-string(div));
format-out(": ");
format-out(integer-to-string(floor/($maximum-integer, div)));
format-out(" vs ");
format-out(integer-to-string(- floor/($maximum-integer, div)));
format-out("\n");
if (div > 1) invert(floor/(div, 2)); end;
end;
format-out("Powers:\n");
iterate power ( pow = 48 )
format-out(integer-to-string(pow));
format-out(": ");
format-out(integer-to-string(2 ^ pow));
format-out(" vs ");
format-out(integer-to-string(- (2 ^ pow)));
format-out("\n");
if (pow > 1) power(pow - 1); end;
end;
format-out(integer-to-string(-1073741824));
format-out("\n");
let underflow = -2147483648;
format-out(integer-to-string(floor/(underflow, 1024)));
format-out("\n");
format-out(integer-to-string(underflow));
format-out("\n");
format-out("End main()\n");
end;
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment