login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for SandBoxMaxSingleInteger revision 5 of 5

1 2 3 4 5
Editor: test1
Time: 2015/06/16 16:40:13 GMT+0
Note:

changed:
-The maximum of AxiomIssues is not really maximal.
The maximum of FriCASIssues is not really maximal.

changed:
-)abbrev package MYSINT AxiomIssues
-AxiomIssues : Public == Private
)abbrev package MYSINT FriCASIssues
FriCASIssues : Public == Private

changed:
-a: AxiomIssues := max()$AxiomIssues
-m: AxiomIssues := mymax()
-m2: AxiomIssues := mymax2()
a: FriCASIssues := max()$FriCASIssues
m: FriCASIssues := mymax()
m2: FriCASIssues := mymax2()

changed:
-b: AxiomIssues := 2^63-1
-c: AxiomIssues := b+1
b: FriCASIssues := 2^63-1
c: FriCASIssues := b+1

changed:
-(1) -> m: AxiomIssues := mymax()
(1) -> m: FriCASIssues := mymax()

changed:
-                                                          Type: AxiomIssues
-(2) -> m2: AxiomIssues := mymax2()
                                                          Type: FriCASIssues
(2) -> m2: FriCASIssues := mymax2()

changed:
-                                                          Type: AxiomIssues
                                                          Type: FriCASIssues

changed:
-(4) -> b: AxiomIssues := 2^63-1
(4) -> b: FriCASIssues := 2^63-1

changed:
-                                                          Type: AxiomIssues
-(5) -> c: AxiomIssues := b+1
                                                          Type: FriCASIssues
(5) -> c: FriCASIssues := b+1

changed:
-                                                          Type: AxiomIssues
                                                          Type: FriCASIssues

The maximum of FriCASIssues is not really maximal.

fricas
(1) -> <spad>
fricas
)abbrev package MYSINT FriCASIssues
FriCASIssues : Public == Private
  where
    Public == IntegerNumberSystem with
      max : () -> %
      mymax : () -> %
      mymax2 : () -> %
    Private  == SingleInteger add
      mymax() == max() + 1
      mymax2() == mymax() + 1</spad>
fricas
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.01 SEC.
compiling exported mymax2 : () -> % Time: 0 SEC.
(time taken in buildFunctor: 2402)
;;; *** |FriCASIssues| REDEFINED
;;; *** |FriCASIssues| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor FriCASIssues Time: 0.02 seconds
(|RealConstant|) extends (|ConvertibleTo| (|DoubleFloat|)) but not (|ConvertibleTo| (|String|)) --------------non extending category---------------------- .. FriCASIssues of cat (|Join| (|IntegerNumberSystem|) (CATEGORY |domain| (SIGNATURE |max| (%)) (SIGNATURE |mymax| (%)) (SIGNATURE |mymax2| (%)))) has no (|ConvertibleTo| (|String|)) finalizing NRLIB MYSINT Processing FriCASIssues for Browser database: --->-->FriCASIssues(constructor): Not documented!!!! --->-->FriCASIssues((max (%))): Not documented!!!! --->-->FriCASIssues((mymax (%))): Not documented!!!! --->-->FriCASIssues((mymax2 (%))): Not documented!!!! --->-->FriCASIssues(): Missing Description ; compiling file "/var/aw/var/LatexWiki/MYSINT.NRLIB/MYSINT.lsp" (written 28 NOV 2024 09:39:08 AM):
; wrote /var/aw/var/LatexWiki/MYSINT.NRLIB/MYSINT.fasl ; compilation finished in 0:00:00.008 ------------------------------------------------------------------------ FriCASIssues is now explicitly exposed in frame initial FriCASIssues will be automatically loaded when needed from /var/aw/var/LatexWiki/MYSINT.NRLIB/MYSINT

fricas
a: FriCASIssues := max()$FriCASIssues

\label{eq1}4611686018427387903(1)
fricas
m: FriCASIssues := mymax()
>> System error: The value 4611686018427387904 is not of type FIXNUM

On my 32 bit system I get


(1) -> )co aaa.spad</p>
<h2>(1) -> m: <a href=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="816" height="1056"/>

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.