The maximum of FriCASIssues is not really maximal. spad )abbrev package MYSINT FriCASIssues FriCASIssues : Public == Private where Public == IntegerNumberSystem with max : () -> % mymax : () -> % mymax2 : () -> % Private == SingleInteger add mymax() == max() + 1 mymax2() == mymax() + 1 spad Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/1558850444918824065-25px001.spad using old system compiler. MYSINT abbreviates package FriCASIssues ------------------------------------------------------------------------ initializing NRLIB MYSINT for FriCASIssues compiling into NRLIB MYSINT compiling exported mymax : () -> $ Time: 0.03 SEC. fricas a: FriCASIssues := max()$FriCASIssues
Type: FriCASIssues
fricas m: FriCASIssues := mymax() On my 32 bit system I get FriCASIssues := mymax() (1) - 2147483648 Type: FriCASIssues (2) -> m2: FriCASIssues := mymax2() (2) - 2147483647 Type: FriCASIssues (3) -> (2^31, 2^32, 2^63, 2^64) (3) [2147483648,4294967296,9223372036854775808,18446744073709551616]? Type: Tuple PositiveInteger? (4) -> b: FriCASIssues := 2^63-1 (4) - 1 Type: FriCASIssues (5) -> c: FriCASIssues := b+1 (5) 0 Type: FriCASIssues " title=" (1) -> )co aaa.spad (1) -> m: FriCASIssues := mymax()(1) - 2147483648 Type: FriCASIssues (2) -> m2: FriCASIssues := mymax2() (2) - 2147483647 Type: FriCASIssues (3) -> (2^31, 2^32, 2^63, 2^64) (3) [2147483648,4294967296,9223372036854775808,18446744073709551616]? Type: Tuple PositiveInteger? (4) -> b: FriCASIssues := 2^63-1 (4) - 1 Type: FriCASIssues (5) -> c: FriCASIssues := b+1 (5) 0 Type: FriCASIssues " class="equation" src="images/5463052088287443490-16.0px.png" align="bottom" Style="vertical-align:text-bottom" width="560" height="420"/> ... --test1, Fri, 22 Mar 2013 21:58:34 +0000 reply SingleInteger? is a low level type. Attempting to use values above max is a user error. Such an error may be
detected or may produce "correct" result or may lead to some weird problem seemingly unrelated to the
error. Basically, using SingleInteger? is a promise by the user that values will stay within bounds.
So do not lie to the compiler.
Concerning the results: I guess they are due to different Lisp implementations. SBCL used here by default is rather strict in error checking. AFAIK Clisp does not care, it produces "correct" results. With other (unsafe) settings in SBCL or with some other Lisp one can get silent corruption possibly leading to crash. |