ArithmeticValue.st
author Claus Gittinger <cg@exept.de>
Sat, 23 Nov 2019 17:01:52 +0100
changeset 24956 dc04e2668278
parent 24861 68e1f568f097
child 24963 3f40782dfac4
permissions -rw-r--r--
#DOCUMENTATION by exept class: ArithmeticValue changed: #basicRaisedToInteger:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
213
3b56a17534fd *** empty log message ***
claus
parents: 155
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
5948
1fc30f692713 new class based exceptions
Claus Gittinger <cg@exept.de>
parents: 5238
diff changeset
    12
"{ Package: 'stx:libbasic' }"
1fc30f692713 new class based exceptions
Claus Gittinger <cg@exept.de>
parents: 5238
diff changeset
    13
17336
3cfe5fb7201c class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 17223
diff changeset
    14
"{ NameSpace: Smalltalk }"
3cfe5fb7201c class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 17223
diff changeset
    15
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    16
Magnitude subclass:#ArithmeticValue
1172
b135d4ae4bf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    17
	instanceVariableNames:''
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
    18
	classVariableNames:'ArithmeticSignal ConversionErrorSignal DivisionByZeroSignal
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
    19
		DomainErrorSignal OverflowSignal UnderflowSignal UnorderedSignal'
1172
b135d4ae4bf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    20
	poolDictionaries:''
b135d4ae4bf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    21
	category:'Magnitude-Numbers'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    22
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    23
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    24
!ArithmeticValue class methodsFor:'documentation'!
82
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    25
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    26
copyright
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    27
"
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    28
 COPYRIGHT (c) 1993 by Claus Gittinger
213
3b56a17534fd *** empty log message ***
claus
parents: 155
diff changeset
    29
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    30
82
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    31
 This software is furnished under a license and may be used
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    32
 only in accordance with the terms of that license and with the
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    34
 be provided or otherwise made available to, or used by, any
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    35
 other person.  No title to or ownership of the software is
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    36
 hereby transferred.
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    37
"
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    38
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    39
82
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    40
documentation
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    41
"
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    42
    ArithmeticValue is an abstract superclass for all things responding to
155
edd7fc34e104 *** empty log message ***
claus
parents: 92
diff changeset
    43
    arithmetic messages. It was inserted into the hierarchy, to allow objects
edd7fc34e104 *** empty log message ***
claus
parents: 92
diff changeset
    44
    like matrices, functions etc. to share the arithmetic methods defined here.
edd7fc34e104 *** empty log message ***
claus
parents: 92
diff changeset
    45
5955
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
    46
    Notice, that what used to be signals are now exception classes - the class
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
    47
    variables and signal accessors remain here for backward compatibility.
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
    48
1283
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
    49
    [class variables:]
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    50
        ArithmeticSignal        <Error>         parent of all arithmetic signals
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    51
                                                (never raised itself)
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    52
                                                New: now a reference to ArithmeticError
82
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    53
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    54
        DomainErrorSignal       <Error>         raised upon float errors
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    55
                                                (for example range in trigonometric)
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    56
                                                New: now a reference to DomainError; no longer a classVar
1283
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
    57
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    58
        DivisionByZeroSignal    <Error>         raised when division by 0 is attempted
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    59
                                                New: now a reference to ZeroDivide
155
edd7fc34e104 *** empty log message ***
claus
parents: 92
diff changeset
    60
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    61
        OverflowSignal          <Error>         raised on overflow/underflow conditions
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    62
        UnderflowSignal                         in float arithmetic.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    63
                                                Notice: some OperatingSystems do not
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    64
                                                provide enough information for ST/X to
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    65
                                                extract the real reason for the floatException
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    66
                                                thus raising DomainErrorSignal in these cases.
155
edd7fc34e104 *** empty log message ***
claus
parents: 92
diff changeset
    67
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
    68
    [author:]
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    69
        Claus Gittinger
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
    70
1283
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
    71
    [See also:]
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
    72
        Number
82
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    73
"
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    74
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    75
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    76
!ArithmeticValue class methodsFor:'Signal constants'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    77
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    78
arithmeticSignal
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    79
    "return the parent of all arithmetic signals"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    80
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
    81
    ^ ArithmeticError
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    82
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    83
23645
c1d740fc821d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23499
diff changeset
    84
coercionErrorSignal
c1d740fc821d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23499
diff changeset
    85
    ^ ArithmeticError
c1d740fc821d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23499
diff changeset
    86
c1d740fc821d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23499
diff changeset
    87
    "Created: / 26-01-2019 / 10:53:12 / Claus Gittinger"
c1d740fc821d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23499
diff changeset
    88
!
c1d740fc821d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23499
diff changeset
    89
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    90
divisionByZeroSignal
21865
15d10ac57835 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21862
diff changeset
    91
    "return the signal which is raised on division by zero.
15d10ac57835 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21862
diff changeset
    92
     No longer used - we now have the class based ZeroDivide exception.
15d10ac57835 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21862
diff changeset
    93
     This method is kept for backward compatibility."
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    94
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
    95
    ^ ZeroDivide
21865
15d10ac57835 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21862
diff changeset
    96
15d10ac57835 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21862
diff changeset
    97
    "Modified (comment): / 20-06-2017 / 17:53:33 / cg"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    98
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    99
a27a279701f8 Initial revision
claus
parents:
diff changeset
   100
domainErrorSignal
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   101
    "return the signal which is raised on some math errors,
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   102
     when the argument is outside the legal domain.
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   103
     (such as arcSin of 2 etc.)"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   104
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   105
    ^ DomainError
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   106
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   107
    "
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   108
     2 arcSin
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   109
     0 log     - raises infiniteResult, which is a child of DomainError
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   110
    "
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   111
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   112
    "Modified (comment): / 22-09-2017 / 09:50:41 / cg"
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   113
!
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   114
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   115
imaginaryResultSignal
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   116
    "return the signal which is raised when an imaginary result would be created
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   117
     (such as when taking the sqrt of a negative number).
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   118
     This error can be handled by wrapping the computation inside a trapImaginary
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   119
     block; then, a complex result is generated."
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   120
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   121
    ^ ImaginaryResultError
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   122
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   123
    "
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   124
     -2 sqrt
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   125
     
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   126
     Complex trapImaginary:[ -2 sqrt ]
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   127
    "
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   128
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   129
    "Modified (comment): / 22-09-2017 / 09:53:58 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   130
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   131
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   132
infiniteResultSignal
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   133
    "return the signal which is raised when an infinite result would be created.
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   134
     This is a subclass of DomainError.
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   135
     (such as when taking the logarithm of zero)"
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   136
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   137
    ^ InfiniteResultError
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   138
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   139
    "Created: / 03-07-2017 / 15:46:02 / cg"
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   140
    "Modified (comment): / 22-09-2017 / 09:49:15 / cg"
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   141
!
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   142
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   143
operationNotPossibleSignal
23645
c1d740fc821d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23499
diff changeset
   144
    ^ ArithmeticError
c1d740fc821d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23499
diff changeset
   145
c1d740fc821d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23499
diff changeset
   146
    "Modified: / 26-01-2019 / 10:54:35 / Claus Gittinger"
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   147
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   148
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   149
overflowSignal
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   150
    "return the signal which is raised on overflow conditions (in floats).
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   151
     Attention: currently not raised on all architectures; some return NaN"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   152
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   153
    ^ OverflowError
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   154
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   155
    "
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   156
     10e300 * 10e30
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   157
     
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   158
     10q300 * 10e30
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   159
    "
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   160
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   161
    "Modified (comment): / 22-09-2017 / 09:58:49 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   162
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   163
5955
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   164
rangeErrorSignal
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   165
    "return the parent of the overflow/underflow signals"
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   166
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   167
    ^ RangeError
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   168
!
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   169
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   170
undefinedResultSignal
23645
c1d740fc821d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23499
diff changeset
   171
    ^ ArithmeticError
c1d740fc821d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23499
diff changeset
   172
c1d740fc821d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23499
diff changeset
   173
    "Modified: / 26-01-2019 / 10:54:28 / Claus Gittinger"
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   174
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   175
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   176
underflowSignal
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   177
    "return the signal which is raised on underflow conditions (in floats)
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   178
     Attention: currently not raised on all architectures; some return zero"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   179
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   180
    ^ UnderflowError
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   181
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   182
    "
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   183
     10e-300 / 10e30
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   184
    "
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   185
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   186
    "Modified (comment): / 22-09-2017 / 09:58:57 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   187
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   188
345
claus
parents: 326
diff changeset
   189
unorderedSignal
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   190
    "return the signal which is raised when numbers are compared,
345
claus
parents: 326
diff changeset
   191
     for which no ordering is defined (for example: complex numbers)"
claus
parents: 326
diff changeset
   192
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   193
    ^ UnorderedNumbersError
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   194
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   195
    "
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   196
     (0 + 3i) > (0 + 4i)
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   197
     3i > 4i
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   198
    "
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   199
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   200
    "Modified (comment): / 22-09-2017 / 09:57:28 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   201
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   202
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   203
!ArithmeticValue class methodsFor:'class initialization'!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   204
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   205
initialize
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   206
    "setup the signals"
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   207
20094
58ebd2ae8adc #OTHER by mawalch
mawalch
parents: 20090
diff changeset
   208
    "/ Notice that we now use class based exceptions;
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   209
    "/ however, for backward compatibility, the class variables
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   210
    "/ referring to those are kept for a while, for subclass compatibility.
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   211
    "/ Please convert your code to access those via the Signal-constants class
20090
2fecd6f6a1b1 #OTHER by mawalch
mawalch
parents: 20060
diff changeset
   212
    "/ messages (accessors) instead of referring to the class variables.
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   213
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   214
    ArithmeticSignal := ArithmeticError.
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   215
    "/ DomainErrorSignal := DomainError.
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   216
    DivisionByZeroSignal := ZeroDivide.
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   217
    UnorderedSignal := UnorderedNumbersError.
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   218
    ConversionErrorSignal := ConversionError.
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   219
    OverflowSignal := OverflowError.
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   220
    UnderflowSignal := UnderflowError.
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   221
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   222
    "Modified: / 03-07-2017 / 14:05:10 / cg"
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   223
! !
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   224
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   225
!ArithmeticValue class methodsFor:'coercing & converting'!
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   226
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   227
coerce:aNumber
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   228
    "convert the argument aNumber into an instance of the receiver (class) and return it."
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   229
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   230
    ^ self subclassResponsibility
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   231
! !
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   232
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   233
!ArithmeticValue class methodsFor:'constants'!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   234
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   235
NaN
8850
b9a04c753bfa comments
Claus Gittinger <cg@exept.de>
parents: 8757
diff changeset
   236
    "return the constant NaN (not a Number)."
b9a04c753bfa comments
Claus Gittinger <cg@exept.de>
parents: 8757
diff changeset
   237
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   238
    ^ NotANumber new
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   239
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   240
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   241
infinity
24301
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   242
    "return something which represents positive infinity.
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   243
     Warning: do not compare equal against infinities;
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   244
     instead, check using isFinite or isInfinite"
8850
b9a04c753bfa comments
Claus Gittinger <cg@exept.de>
parents: 8757
diff changeset
   245
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   246
    ^ Infinity positive
21862
f5727dd0658a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21831
diff changeset
   247
f5727dd0658a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21831
diff changeset
   248
    "Modified (comment): / 20-06-2017 / 13:45:23 / cg"
24301
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   249
    "Modified (comment): / 09-06-2019 / 12:56:30 / Claus Gittinger"
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   250
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   251
7538
dd0131e05cf0 Define #nan for VW-compatibility
Stefan Vogel <sv@exept.de>
parents: 7471
diff changeset
   252
nan
dd0131e05cf0 Define #nan for VW-compatibility
Stefan Vogel <sv@exept.de>
parents: 7471
diff changeset
   253
    "VW compatibility"
dd0131e05cf0 Define #nan for VW-compatibility
Stefan Vogel <sv@exept.de>
parents: 7471
diff changeset
   254
dd0131e05cf0 Define #nan for VW-compatibility
Stefan Vogel <sv@exept.de>
parents: 7471
diff changeset
   255
    ^ self NaN
dd0131e05cf0 Define #nan for VW-compatibility
Stefan Vogel <sv@exept.de>
parents: 7471
diff changeset
   256
!
dd0131e05cf0 Define #nan for VW-compatibility
Stefan Vogel <sv@exept.de>
parents: 7471
diff changeset
   257
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   258
negativeInfinity
24301
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   259
    "return something which represents negative infinity.
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   260
     Warning: do not compare equal against infinities;
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   261
     instead, check using isFinite or isInfinite"
8850
b9a04c753bfa comments
Claus Gittinger <cg@exept.de>
parents: 8757
diff changeset
   262
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   263
    ^ Infinity negative
24301
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   264
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   265
    "Modified (comment): / 09-06-2019 / 12:56:36 / Claus Gittinger"
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   266
!
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   267
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   268
positiveInfinity
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   269
    "return something which represents positive infinity.
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   270
     Warning: do not compare equal against infinities;
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   271
     instead, check using isFinite or isInfinite"
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   272
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   273
    ^ self infinity
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   274
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   275
    "Created: / 09-06-2019 / 12:49:31 / Claus Gittinger"
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   276
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   277
7726
a3bb3ae6c02e Define #unity
Stefan Vogel <sv@exept.de>
parents: 7635
diff changeset
   278
unity
11467
f2bdc4080cac comments
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   279
    "return something which represents the unity element (for my instances).
f2bdc4080cac comments
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   280
     That is the neutral element for multiplication."
8850
b9a04c753bfa comments
Claus Gittinger <cg@exept.de>
parents: 8757
diff changeset
   281
21827
a3f2ce15176f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21816
diff changeset
   282
    ^ self subclassResponsibility
a3f2ce15176f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21816
diff changeset
   283
a3f2ce15176f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21816
diff changeset
   284
    "Modified: / 16-06-2017 / 11:04:36 / cg"
7726
a3bb3ae6c02e Define #unity
Stefan Vogel <sv@exept.de>
parents: 7635
diff changeset
   285
!
a3bb3ae6c02e Define #unity
Stefan Vogel <sv@exept.de>
parents: 7635
diff changeset
   286
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   287
zero
11467
f2bdc4080cac comments
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   288
    "return something which represents the zero element (for my instances).
f2bdc4080cac comments
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   289
     That is the neutral element for addition."
8850
b9a04c753bfa comments
Claus Gittinger <cg@exept.de>
parents: 8757
diff changeset
   290
21827
a3f2ce15176f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21816
diff changeset
   291
    ^ self subclassResponsibility
a3f2ce15176f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21816
diff changeset
   292
a3f2ce15176f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21816
diff changeset
   293
    "Modified: / 16-06-2017 / 11:04:33 / cg"
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   294
! !
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   295
17223
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   296
!ArithmeticValue class methodsFor:'error reporting'!
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   297
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   298
raise:aSignalSymbolOrErrorClass receiver:someNumber selector:sel arguments:argArray errorString:text 
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   299
    "ST-80 compatible signal raising. Provided for PD numeric classes.
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   300
     aSignalSymbolOrErrorClass is either an Error-subclass, or
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   301
     the selector which is sent to myself, to retrieve the Exception class / Signal."
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   302
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   303
    <context: #return>
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   304
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   305
    |msg signalOrException|
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   306
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   307
    msg := MessageSend
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   308
                receiver:someNumber
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   309
                selector:sel
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   310
                arguments:argArray.
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   311
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   312
    aSignalSymbolOrErrorClass isSymbol ifTrue:[
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   313
        signalOrException := self perform:aSignalSymbolOrErrorClass.
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   314
    ] ifFalse:[
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   315
        signalOrException := aSignalSymbolOrErrorClass.    "/ assume its an Error-Subclass
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   316
    ].
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   317
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   318
    ^ signalOrException
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   319
         raiseRequestWith:msg 
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   320
         errorString:text 
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   321
         in:thisContext sender
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   322
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   323
    "
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   324
     Number 
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   325
        raise:#domainErrorSignal
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   326
        receiver:1.0
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   327
        selector:#foo 
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   328
        errorString:'foo bar test'
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   329
    "
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   330
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   331
    "Modified: / 16.11.2001 / 14:12:09 / cg"
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   332
! !
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
   333
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   334
!ArithmeticValue class methodsFor:'exception handling'!
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   335
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   336
trapImaginary:aBlock
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   337
    "evaluate aBlock; 
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   338
     if any ImaginaryResult occurs inside, which would return an imaginary result, 
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   339
     (eg. square root of negative number),
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   340
     convert the result to a complex number and proceed.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   341
     
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   342
     This allows for regular (failing) code to transparently convert to complex."
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   343
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   344
    ^ ImaginaryResultError 
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   345
        handle: [:ex |
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   346
            |msgSend selector rcvr|
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   347
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   348
            msgSend := ex parameter.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   349
            selector := msgSend selector.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   350
            rcvr := msgSend receiver.
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   351
            
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   352
            (selector == #sqrt or: [selector == #sqrtTruncated]) ifTrue: [
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   353
                (rcvr isNumber and:[rcvr isReal]) ifTrue:[
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   354
                    ex proceedWith:(rcvr abs perform:selector) i
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   355
                ] ifFalse:[    
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   356
                    msgSend receiver: rcvr asComplex.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   357
                    ex proceedWith: msgSend value
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   358
                ].
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   359
            ] ifFalse: [
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   360
                (selector == #integerSqrt) ifTrue: [
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   361
                    (rcvr isInteger) ifTrue:[
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   362
                        ex proceedWith:(rcvr abs integerSqrt) i
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   363
                    ] ifFalse:[
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   364
                        ex proceedWith:(rcvr abs asComplex sqrt floor) i
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   365
                    ].    
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   366
                ] ifFalse: [
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   367
                    (selector == #nthRoot:) ifTrue: [
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   368
                        ex proceedWith:(rcvr abs nthRoot:msgSend argument) i
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   369
                    ]
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   370
                ]
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   371
            ].
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   372
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   373
            ex reject
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   374
        ] do: 
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   375
            aBlock
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   376
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   377
    "
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   378
     this raises an error:
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   379
         -2 sqrt
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   380
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   381
     this returns an imaginary result:
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   382
         Complex trapImaginary: [-2 sqrt]
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   383
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   384
     of course, this one as well:
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   385
         -2 asComplex sqrt
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   386
    "
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   387
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   388
    "failing code:
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   389
         |a|
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   390
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   391
         a := -2.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   392
         (a sqrt + 5) * 17.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   393
    "
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   394
    "complex code:
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   395
         |a|
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   396
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   397
         Complex trapImaginary:[
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   398
             a := -2.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   399
             (a sqrt + 5) * 2.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   400
         ]
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   401
    "
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   402
22289
32494a092b95 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21991
diff changeset
   403
    "Modified: / 22-09-2017 / 10:18:14 / cg"
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   404
!
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   405
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   406
trapInfinity:aBlock
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   407
    "evaluate aBlock; 
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   408
     if any DomainError occurs inside, which would return an infinite result, 
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   409
     (eg. ln of zero),
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   410
     convert the result to infinity and proceed.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   411
     
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   412
     This allows for regular (failing) code to transparently convert to infinity and behave
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   413
     similar to other systems which do that."
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   414
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   415
    ^ InfiniteResultError 
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   416
        handle: [:ex |
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   417
            |msgSend selector rcvr|
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   418
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   419
            msgSend := ex parameter.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   420
            selector := msgSend selector.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   421
            rcvr := msgSend receiver.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   422
            ((selector == #ln) 
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   423
            or:[selector == #log10
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   424
            or:[selector == #integerLog10]]) ifTrue: [
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   425
                (rcvr isNumber) ifTrue:[
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   426
                    ex proceedWith:(rcvr class negativeInfinity )
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   427
                ].
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   428
            ].
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   429
            ex reject
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   430
        ] do: 
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   431
            aBlock
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   432
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   433
    "
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   434
     this raises an error:
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   435
         0 ln
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   436
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   437
     this returns an imaginary result:
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   438
         Number trapInfinity: [0 ln]
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   439
    "
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   440
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   441
    "failing code:
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   442
         |a|
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   443
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   444
         a := 0.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   445
         a ln isFinite.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   446
    "
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   447
    "fixed code:
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   448
         |a|
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   449
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   450
         Number trapInfinity:[
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   451
             a := 0.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   452
             a ln isFinite.
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   453
         ]
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   454
    "
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   455
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   456
    "Created: / 03-07-2017 / 14:25:57 / cg"
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   457
    "Modified: / 03-07-2017 / 15:53:40 / cg"
21991
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   458
!
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   459
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   460
trapOverflow:aBlock
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   461
    "evaluate aBlock; 
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   462
     if an Overflow occurs inside, return INF and proceed."
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   463
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   464
    ^ OverflowError 
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   465
        handle: [:ex |
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   466
            |msgSend rcvr|
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   467
            
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   468
            msgSend := ex parameter.
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   469
            rcvr := msgSend receiver.
24301
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   470
            ex proceedWith:(rcvr class positiveInfinity)
21991
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   471
        ] do: 
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   472
            aBlock
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   473
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   474
    "
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   475
     this raises an error:
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   476
         1000 factorial asShortFloat
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   477
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   478
     this returns an imaginary result:
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   479
         Number trapOverflow: [ 1000 factorial asShortFloat]
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   480
    "
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   481
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   482
    "Created: / 07-07-2017 / 13:08:06 / cg"
24301
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   483
    "Modified: / 09-06-2019 / 12:53:55 / Claus Gittinger"
21991
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   484
!
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   485
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   486
trapUnderflow:aBlock
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   487
    "evaluate aBlock; 
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   488
     if an Underflow occurs inside, return zero and proceed."
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   489
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   490
    ^ UnderflowError 
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   491
        handle: [:ex |
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   492
            |msgSend rcvr|
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   493
            
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   494
            msgSend := ex parameter.
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   495
            rcvr := msgSend receiver.
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   496
            ex proceedWith:(rcvr class zero)
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   497
        ] do: 
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   498
            aBlock
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   499
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   500
    "
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   501
     this raises an error:
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   502
         1.0 / (1000 factorial)
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   503
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   504
     this returns an imaginary result:
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   505
         Number trapUnderflow: 1.0 / (1000 factorial)]
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   506
    "
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   507
0533f6b00cce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21967
diff changeset
   508
    "Created: / 05-07-2017 / 13:16:43 / cg"
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   509
! !
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
   510
8892
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8850
diff changeset
   511
!ArithmeticValue class methodsFor:'queries'!
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8850
diff changeset
   512
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8850
diff changeset
   513
isAbstract
11227
c4f57b8aca5a comment
Claus Gittinger <cg@exept.de>
parents: 11133
diff changeset
   514
    "Return if this class is an abstract class.
c4f57b8aca5a comment
Claus Gittinger <cg@exept.de>
parents: 11133
diff changeset
   515
     True is returned for ArithmeticValue here; false for subclasses.
19454
895593647d58 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19056
diff changeset
   516
     Abstract subclasses must redefine this again."
11227
c4f57b8aca5a comment
Claus Gittinger <cg@exept.de>
parents: 11133
diff changeset
   517
8892
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8850
diff changeset
   518
    ^ self == ArithmeticValue
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8850
diff changeset
   519
! !
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8850
diff changeset
   520
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   521
!ArithmeticValue methodsFor:'arithmetic'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   522
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   523
* something
11735
60aa644effbe comment
Claus Gittinger <cg@exept.de>
parents: 11725
diff changeset
   524
    "return the product of the receiver and the argument."
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   525
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   526
    ^ self subclassResponsibility
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   527
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   528
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   529
+ something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   530
    "return the sum of the receiver and the argument"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   531
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   532
    ^ self subclassResponsibility
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   533
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   534
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   535
- something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   536
    "return the difference of the receiver and the argument"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   537
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   538
    ^ self subclassResponsibility
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   539
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   540
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   541
/ something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   542
    "return the quotient of the receiver and the argument"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   543
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   544
    ^ self subclassResponsibility
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   545
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   546
22358
101b2548022b #DOCUMENTATION by mawalch
mawalch
parents: 22289
diff changeset
   547
// aNumber
1881
0c6ba2c134c1 fixed #rounded
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   548
    "return the integer quotient of dividing the receiver by aNumber with
20337
8ea0078f0179 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20094
diff changeset
   549
     truncation towards negative infinity.
22358
101b2548022b #DOCUMENTATION by mawalch
mawalch
parents: 22289
diff changeset
   550
20338
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   551
     Please be aware of the effect of truncation on negative receivers,
20337
8ea0078f0179 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20094
diff changeset
   552
     and understand the difference between '//' vs. 'quo:'
8ea0078f0179 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20094
diff changeset
   553
     and the corresponding '\\' vs. 'rem:'"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   554
22358
101b2548022b #DOCUMENTATION by mawalch
mawalch
parents: 22289
diff changeset
   555
    "/ Note: '^ (self / aNumber) floor' may lead to infinite recursion
1172
b135d4ae4bf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   556
b135d4ae4bf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   557
    ^ self subclassResponsibility
b135d4ae4bf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   558
22358
101b2548022b #DOCUMENTATION by mawalch
mawalch
parents: 22289
diff changeset
   559
    "Modified: / 05-11-1996 / 11:46:27 / cg"
101b2548022b #DOCUMENTATION by mawalch
mawalch
parents: 22289
diff changeset
   560
    "Modified: / 12-02-1998 / 16:31:36 / stefan"
101b2548022b #DOCUMENTATION by mawalch
mawalch
parents: 22289
diff changeset
   561
    "Modified (comment): / 16-11-2017 / 11:26:13 / mawalch"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   562
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   563
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   564
\\ something
3982
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   565
    "return the receiver modulo something.
17038
e5e3568f805e class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 16657
diff changeset
   566
     The remainder has the same sign as the argument, something.
6067
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   567
     The following is always true:
17038
e5e3568f805e class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 16657
diff changeset
   568
        (receiver // something) * something + (receiver \\ something) = receiver
20338
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   569
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   570
     Please be aware of the effect of truncation on negative receivers,
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   571
     and understand the difference between '//' vs. 'quo:'
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   572
     and the corresponding '\\' vs. 'rem:'."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   573
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   574
    ^ self - ((self // something) * something)
3134
22c7071ff004 Fix typo.
Stefan Vogel <sv@exept.de>
parents: 1888
diff changeset
   575
3982
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   576
   "
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   577
     0.9 \\ 0.4
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   578
     0.9 \\ -0.4
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   579
    -0.9 \\ 0.4
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   580
    -0.9 \\ -0.4
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   581
   "
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   582
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   583
    "Modified: / 12.2.1998 / 19:14:37 / stefan"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   584
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   585
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   586
abs
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   587
    "return the absolute value of the receiver"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   588
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   589
    (self negative) ifTrue:[^ self negated].
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   590
    ^ self
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   591
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   592
22723
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   593
copySignTo:aNumber
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   594
    "Return a number with same magnitude as aNumber and same sign as self"
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   595
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   596
    (self negative == aNumber negative) ifTrue:[^ aNumber].
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   597
    ^ aNumber negated
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   598
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   599
    "
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   600
     -15 copySignTo:1234  -> -1234
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   601
     -15 copySignTo:-1234 -> -1234
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   602
     15 copySignTo:1234   -> 1234
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   603
     15 copySignTo:-1234  -> 1234
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   604
     1.0 copySignTo:0.0   -> 0.0 
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   605
     -1.0 copySignTo:0.0  -> -0.0
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   606
     1 copySignTo:(1/3)   -> (1/3) 
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   607
     -1 copySignTo:(1/3)  -> (-1/3)
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   608
    "
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   609
!
5e9e074b1c0f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22358
diff changeset
   610
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   611
dist:arg
20696
2fb95c98ed4a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20353
diff changeset
   612
    "return the distance between the arg and the receiver."
8757
Claus Gittinger <cg@exept.de>
parents: 8633
diff changeset
   613
Claus Gittinger <cg@exept.de>
parents: 8633
diff changeset
   614
    ^ (arg - self) abs
Claus Gittinger <cg@exept.de>
parents: 8633
diff changeset
   615
Claus Gittinger <cg@exept.de>
parents: 8633
diff changeset
   616
    "
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   617
     (1%1) dist:(0%0)
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   618
     (1@1) dist:(0@0)
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   619
     (1) dist:(0)
8757
Claus Gittinger <cg@exept.de>
parents: 8633
diff changeset
   620
    "
Claus Gittinger <cg@exept.de>
parents: 8633
diff changeset
   621
!
Claus Gittinger <cg@exept.de>
parents: 8633
diff changeset
   622
16121
7b441c381015 class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 15279
diff changeset
   623
modulusOf:aNumber
20353
500460b04523 #OTHER by mawalch
mawalch
parents: 20338
diff changeset
   624
    "return aNumber modulo the receiver.
16121
7b441c381015 class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 15279
diff changeset
   625
     The remainder has the same sign as something.
7b441c381015 class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 15279
diff changeset
   626
     Defined for protocol compatibility with ModuloNumber."
7b441c381015 class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 15279
diff changeset
   627
7b441c381015 class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 15279
diff changeset
   628
    ^ aNumber \\ self
7b441c381015 class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 15279
diff changeset
   629
!
7b441c381015 class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 15279
diff changeset
   630
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   631
negated
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   632
    "return the receiver negated"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   633
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   634
    ^ self class zero - self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   635
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   636
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   637
quo:something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   638
    "Return the integer quotient of dividing the receiver by the argument
6067
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   639
     with truncation towards zero.
20338
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   640
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   641
     Please be aware of the effect of truncation on negative receivers,
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   642
     and understand the difference between '//' vs. 'quo:'
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   643
     and the corresponding '\\' vs. 'rem:'.
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   644
6067
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   645
     The following is always true:
20337
8ea0078f0179 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20094
diff changeset
   646
        (receiver quo: aNumber) * aNumber + (receiver rem: aNumber) = receiver
8ea0078f0179 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20094
diff changeset
   647
     For positive results, this is the same as #//,
8ea0078f0179 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20094
diff changeset
   648
     for negative results, the remainder is ignored.
8ea0078f0179 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20094
diff changeset
   649
     I.e.: '9 // 4 = 2' and '-9 // 4 = -3'
8ea0078f0179 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20094
diff changeset
   650
     in contrast: '9 quo: 4 = 2' and '-9 quo: 4 = -2'"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   651
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   652
    ^ (self / something) truncated
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   653
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   654
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   655
reciprocal
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   656
    "return the receiver's reciprocal"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   657
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   658
    ^ self class unity / self
22731
3381d1e307c5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22723
diff changeset
   659
3381d1e307c5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22723
diff changeset
   660
    "
3381d1e307c5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22723
diff changeset
   661
     (10 + 4i) class unity -> (1+0i)
3381d1e307c5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22723
diff changeset
   662
     (10 + 4i) reciprocal  -> ((5/58)-(1/29)i)
3381d1e307c5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22723
diff changeset
   663
     (4/3) reciprocal  -> (3/4) 
3381d1e307c5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22723
diff changeset
   664
     3 reciprocal  -> (1/3) 
3381d1e307c5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22723
diff changeset
   665
     3.0 reciprocal  -> 0.333333333333333 
3381d1e307c5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22723
diff changeset
   666
     3.0 asLongFloat reciprocal  -> 0.3333333333333333333 
3381d1e307c5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22723
diff changeset
   667
     3.0 asShortFloat reciprocal  -> 0.3333333 
3381d1e307c5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22723
diff changeset
   668
    "
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   669
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   670
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   671
rem:something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   672
    "Return the integer remainder of dividing the receiver by the argument
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   673
     with truncation towards zero.
6067
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   674
     The remainder has the same sign as the receiver.
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   675
     The following is always true:
20338
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   676
        (receiver quo: something) * something + (receiver rem: something) = receiver
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   677
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   678
     Please be aware of the effect of truncation on negative receivers,
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   679
     and understand the difference between '//' vs. 'quo:'
d6c7cb1e32df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20337
diff changeset
   680
     and the corresponding '\\' vs. 'rem:'."
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   681
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   682
    ^ self - ((self quo:something) * something)
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   683
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   684
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   685
uncheckedDivide:aNumber
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   686
    "return the quotient of the receiver and the argument, aNumber.
7471
c5d4bd612d9f comments
Claus Gittinger <cg@exept.de>
parents: 7468
diff changeset
   687
     Do not check for divide by zero (return NaN or Infinity).
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   688
     This operation is provided for emulators of other languages/semantics,
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   689
     where no exception is raised for these results (i.e. Java).
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   690
     It is only defined if the argument's type is the same as the receiver's."
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   691
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   692
    aNumber isZero ifTrue:[
21831
9b13255ce344 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21827
diff changeset
   693
        "/ protect against NaN and negativeInfinity trying to use me...
23158
1d6551c846d0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22731
diff changeset
   694
        thisContext isRecursive ifTrue:[ 
1d6551c846d0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22731
diff changeset
   695
            self error:'recursive #uncheckedDivide:'.
1d6551c846d0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22731
diff changeset
   696
        ].
21831
9b13255ce344 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21827
diff changeset
   697
        
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   698
        self isZero ifTrue:[^ self class NaN].
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   699
        self negative ifTrue:[^ self class negativeInfinity].
24301
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   700
        ^ self class positiveInfinity.
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   701
    ].
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
   702
    ^ self / aNumber
21831
9b13255ce344 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21827
diff changeset
   703
9b13255ce344 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21827
diff changeset
   704
    "Modified (format): / 18-06-2017 / 23:43:13 / cg"
24301
bf2a904cbeda #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24279
diff changeset
   705
    "Modified: / 09-06-2019 / 12:53:47 / Claus Gittinger"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   706
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   707
12578
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   708
!ArithmeticValue methodsFor:'arithmetic destructive'!
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   709
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   710
*= aNumber
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   711
    "Return the product of self multiplied by aNumber.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   712
     The receiver MAY, but NEED NOT be changed to contain the product.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   713
     So this method must be used as: 'a := a *= 5'.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   714
     This method can be redefined for constructed datatypes to do optimisations"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   715
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   716
    ^ self * aNumber
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   717
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   718
    "Created: / 28.4.1999 / 11:46:11 / stefan"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   719
    "Modified: / 28.4.1999 / 11:53:28 / stefan"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   720
!
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   721
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   722
+= aNumber
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   723
    "Return the sum of self and aNumber.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   724
     The receiver MAY, but NEED NOT be changed to contain the sum.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   725
     So this method must be used as: 'a := a += 5'.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   726
     This method can be redefined for constructed datatypes to do optimisations"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   727
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   728
    ^ self + aNumber
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   729
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   730
    "Created: / 28.4.1999 / 10:13:41 / stefan"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   731
    "Modified: / 28.4.1999 / 11:54:11 / stefan"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   732
!
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   733
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   734
-= aNumber
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   735
    "Return the difference of self and aNumber.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   736
     The receiver MAY, but NEED NOT be changed to contain the difference.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   737
     So this method must be used as: 'a := a -= 5'.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   738
     This method can be redefined for constructed datatypes to do optimisations"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   739
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   740
    ^ self - aNumber
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   741
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   742
    "Created: / 28.4.1999 / 10:13:58 / stefan"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   743
    "Modified: / 28.4.1999 / 11:54:37 / stefan"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   744
!
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   745
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   746
/= aNumber
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   747
    "Return the quotient of self and aNumber.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   748
     The receiver MAY, but NEED NOT be changed to contain the quotient.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   749
     So this method must be used as: 'a := a /= 5'.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   750
     This method can be redefined for constructed datatypes to do optimisations"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   751
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   752
    ^ self / aNumber
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   753
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   754
    "Created: / 28.4.1999 / 11:46:22 / stefan"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   755
    "Modified: / 28.4.1999 / 11:55:06 / stefan"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   756
!
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   757
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   758
div2
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   759
    "Return the quotient of self divided by 2.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   760
     The receiver MAY, but NEED NOT be changed to contain the result.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   761
     So this method must be used as: 'a := a div2.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   762
     This method can be redefined for constructed datatypes to do optimisations"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   763
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   764
    ^ self // 2
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   765
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   766
    "Created: / 28.4.1999 / 10:12:44 / stefan"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   767
    "Modified: / 28.4.1999 / 11:56:09 / stefan"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   768
!
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   769
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   770
mul2
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   771
    "Return the product of self multiplied by 2.
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   772
     The receiver MAY, but NEED NOT be changed to contain the result.
15279
7dd8da92779e class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14747
diff changeset
   773
     So this method must be used as: a := a mul2.
12578
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   774
     This method can be redefined for constructed datatypes to do optimisations"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   775
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   776
    ^ self * 2
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   777
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   778
    "Created: / 28.4.1999 / 10:12:55 / stefan"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   779
    "Modified: / 28.4.1999 / 11:56:38 / stefan"
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   780
! !
6cb12eb8eb59 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 12576
diff changeset
   781
5238
f7a816a660a3 categories
Claus Gittinger <cg@exept.de>
parents: 4995
diff changeset
   782
!ArithmeticValue methodsFor:'coercing & converting'!
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   783
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   784
coerce:aNumber
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   785
    "convert the argument aNumber into an instance of the receiver's class and return it."
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   786
21816
3db3da9b3702 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21804
diff changeset
   787
    ^ self class coerce:aNumber
3db3da9b3702 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21804
diff changeset
   788
3db3da9b3702 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21804
diff changeset
   789
    "Modified: / 15-06-2017 / 10:27:03 / cg"
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   790
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   791
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   792
generality
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   793
    "return a number giving the receiver's generality.
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   794
     That number is used to convert one of the arguments in a mixed expression.
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   795
     The generality has to be defined in subclasses,
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   796
     such that gen(a) > gen(b) iff, conversion of b into a's class
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   797
     does not cut precision. 
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   798
     For example, Integer has 40, Float has 80, meaning that if we convert a Float to an Integer, 
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   799
     some precision may be lost. 
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   800
     The generality is used by ArithmeticValue>>retry:coercing:,
3982
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   801
     which converts the lower-precision number to the higher precision
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   802
     number's class, when mixed-type arithmetic is performed."
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   803
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   804
    ^ self subclassResponsibility
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   805
3982
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   806
    "Modified: / 5.11.1996 / 15:05:30 / cg"
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   807
    "Modified: / 13.2.1998 / 15:36:01 / stefan"
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   808
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   809
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   810
retry:aSymbol coercing:aNumber
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   811
    "arithmetic represented by the binary operator, aSymbol,
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   812
     could not be performed with the receiver and the argument, aNumber,
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   813
     because of the differences in representation.
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   814
     Coerce either the receiver or the argument, depending on which has higher
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   815
     generality, and try again.
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   816
     If the operation is compare for same value (=), return false if
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   817
     the argument is not a Number.
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   818
     If the generalities are the same, create an error message, since this
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   819
     means that a subclass has not been fully implemented."
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   820
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   821
    |hasGenerality myGenerality otherGenerality|
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   822
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   823
    hasGenerality := aNumber respondsTo:#generality.
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   824
    hasGenerality ifFalse:[
20060
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   825
        (aSymbol == #=) ifTrue:[
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   826
            ^ false
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   827
        ].
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   828
        (aSymbol == #~=) ifTrue:[
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   829
            ^ true
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   830
        ].
24274
f3a6d4988c82 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23645
diff changeset
   831
        ^ ArgumentError raiseErrorString:'retry:coercing: argument is not a number'.
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   832
    ].
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   833
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   834
    myGenerality := self generality.
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   835
    otherGenerality := aNumber generality.
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   836
    (myGenerality > otherGenerality) ifTrue:[
20060
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   837
        ^ self perform:aSymbol with:(self coerce:aNumber)
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   838
    ].
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   839
    (myGenerality < otherGenerality) ifTrue:[
20060
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   840
        ^ (aNumber coerce:self) perform:aSymbol with:aNumber
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   841
    ].
20060
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   842
"/    self error:'retry:coercing: oops - same generality; retry should not happen'
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   843
     "same generality may happen with Lazy and LazyValue"
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   844
     ^ self perform:aSymbol with:aNumber
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   845
    
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   846
    "
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   847
        ([3] lazyValue) * ([2] lazyValue)
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   848
    "
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   849
24274
f3a6d4988c82 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23645
diff changeset
   850
    "Modified: / 05-11-1996 / 15:03:38 / cg"
f3a6d4988c82 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23645
diff changeset
   851
    "Modified: / 06-06-2019 / 23:27:43 / Claus Gittinger"
16657
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   852
!
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   853
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   854
retry:aSymbol coercing:aNumber with:anArgument
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   855
    "arithmetic represented by the binary operator, aSymbol,
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   856
     could not be performed with the receiver and the argument, aNumber,
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   857
     because of the differences in representation.
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   858
     Coerce either the receiver or the argument, depending on which has higher
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   859
     generality, and try again.
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   860
     If the operation is compare for same value (=), return false if
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   861
     the argument is not a Number.
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   862
     If the generalities are the same, create an error message, since this
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   863
     means that a subclass has not been fully implemented."
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   864
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   865
    |hasGenerality myGenerality otherGenerality|
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   866
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   867
    hasGenerality := aNumber respondsTo:#generality.
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   868
    hasGenerality ifFalse:[
24274
f3a6d4988c82 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23645
diff changeset
   869
        ^ ArgumentError raiseErrorString:'retry:coercing: argument is not a number'.
16657
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   870
    ].
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   871
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   872
    myGenerality := self generality.
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   873
    otherGenerality := aNumber generality.
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   874
    (myGenerality > otherGenerality) ifTrue:[
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   875
        ^ self perform:aSymbol with:(self coerce:aNumber) with:anArgument
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   876
    ].
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   877
    (myGenerality < otherGenerality) ifTrue:[
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   878
        ^ (aNumber coerce:self) perform:aSymbol with:aNumber with:anArgument
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
   879
    ].
20060
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   880
"/    self error:'retry:coercing: oops - same generality; retry should not happen'
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   881
     "same generality may happen with Lazy and LazyValue"
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   882
     ^ self perform:aSymbol with:aNumber with:anArgument
c41b1620a04a #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19454
diff changeset
   883
24274
f3a6d4988c82 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23645
diff changeset
   884
    "Modified: / 05-11-1996 / 15:03:38 / cg"
f3a6d4988c82 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23645
diff changeset
   885
    "Modified: / 06-06-2019 / 23:27:50 / Claus Gittinger"
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   886
! !
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   887
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   888
!ArithmeticValue methodsFor:'converting'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   889
17222
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   890
as32BitIEEEFloatBytesMSB:msb
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   891
    ^ self asShortFloat digitBytesMSB:msb
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   892
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   893
    "
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   894
        2  as32BitIEEEFloatBytesMSB:true
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   895
        2.0  as32BitIEEEFloatBytesMSB:true
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   896
    "
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   897
!
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   898
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   899
as64BitIEEEFloatBytesMSB:msb
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   900
    ^ self asFloat digitBytesMSB:msb
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   901
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   902
    "
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   903
        2  as64BitIEEEFloatBytesMSB:true
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   904
        2.0  as64BitIEEEFloatBytesMSB:true
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   905
    "
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   906
!
9ff268844b9c class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17189
diff changeset
   907
3982
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   908
asDouble
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   909
    "ST80 compatibility: return a double with receiver's value.
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
   910
     Attention: our floats are the identical to ST80's doubles"
3982
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   911
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   912
   ^ self asFloat
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   913
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   914
    "Created: / 13.2.1998 / 15:40:14 / stefan"
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   915
!
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   916
8202
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   917
asFixedPoint
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   918
    "return the receiver as fixedPoint number.
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   919
     Q: what should the scale be here ?"
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   920
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   921
    ^ self asFraction asFixedPoint
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   922
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   923
    "
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   924
     0.3 asFixedPoint
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   925
     0.5 asFixedPoint
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   926
     (1/5) asFloat asFixedPoint
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   927
     (1/3) asFloat asFixedPoint
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   928
     (2/3) asFloat asFixedPoint
8202
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   929
     (1/8) asFloat asFixedPoint
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   930
     3.14159 asFixedPoint
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   931
     0.0000001 asFraction
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   932
     0.0000001 asFixedPoint
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   933
    "
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   934
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   935
    "Modified: / 25.10.1997 / 15:36:54 / cg"
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   936
!
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   937
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   938
asFixedPoint:scale
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   939
    "return the receiver as fixedPoint number with the given
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   940
     number of post-decimal-digits."
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   941
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   942
    ^ self asFraction asFixedPoint:scale
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   943
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   944
    "
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   945
     0.3 asFixedPoint:4
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   946
     0.3 asFixedPoint:3
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   947
     0.3 asFixedPoint:2
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   948
     0.3 asFixedPoint:1
8202
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   949
     0.3 asFixedPoint:0
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   950
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   951
     0.5 asFixedPoint:3
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   952
     (1/5) asFloat asFixedPoint:1
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   953
     (1/8) asFloat asFixedPoint:1
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   954
     1.0 asFixedPoint:2
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   955
     3.14159 asFixedPoint:2
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   956
     3.14159 asFixedPoint:3
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
   957
     (3.14159 asFixedPoint:2) asFixedPoint:5
8202
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   958
    "
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   959
!
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
   960
12980
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   961
asFixedPointRoundedToScale
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   962
    "return the receiver as fixedPoint number, rounded to its scale."
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   963
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   964
    ^ self asFixedPoint roundedToScale
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   965
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   966
    "
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   967
     0.3 asFixedPoint
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   968
     0.5 asFixedPoint
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   969
     (2/3) asFloat asFixedPoint
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   970
     (1/8) asFloat asFixedPoint
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   971
     3.14159 asFixedPoint
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   972
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   973
     0.3 asFixedPointRoundedToScale
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   974
     0.5 asFixedPointRoundedToScale
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   975
     (2/3) asFloat asFixedPointRoundedToScale
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   976
     (1/8) asFloat asFixedPointRoundedToScale
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   977
     3.14159 asFixedPointRoundedToScale
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   978
    "
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   979
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   980
    "Created: / 02-08-2010 / 13:32:16 / cg"
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   981
!
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   982
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   983
asFixedPointRoundedToScale:scale
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   984
    "return the receiver as fixedPoint number with the given
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   985
     number of post-decimal-digits, rounded to its scale"
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   986
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   987
    ^ (self asFixedPoint:scale) roundedToScale
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   988
17336
3cfe5fb7201c class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 17223
diff changeset
   989
    "
3cfe5fb7201c class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 17223
diff changeset
   990
     3.14159 asFixedPointRoundedToScale:1
3cfe5fb7201c class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 17223
diff changeset
   991
     3.14159 asFixedPointRoundedToScale:2
3cfe5fb7201c class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 17223
diff changeset
   992
     3.14159 asFixedPointRoundedToScale:3
3cfe5fb7201c class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 17223
diff changeset
   993
     3.14159 asFixedPointRoundedToScale:4
3cfe5fb7201c class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 17223
diff changeset
   994
    "
3cfe5fb7201c class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 17223
diff changeset
   995
12980
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   996
    "Created: / 02-08-2010 / 13:33:11 / cg"
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   997
!
Claus Gittinger <cg@exept.de>
parents: 12760
diff changeset
   998
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   999
asFloat
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1000
    "return a float with same value"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1001
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1002
   ^ self subclassResponsibility
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1003
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1004
5986
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1005
asFloatD
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1006
    "return a double precision float with same value.
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1007
     Added for ANSI compatibility"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1008
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1009
   ^ self asFloat
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1010
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1011
    "Created: / 7.9.2001 / 13:36:48 / cg"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1012
    "Modified: / 7.9.2001 / 13:38:10 / cg"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1013
!
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1014
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1015
asFloatE
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1016
    "return a single precision float with same value.
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1017
     Added for ANSI compatibility"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1018
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1019
   ^ self asShortFloat
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1020
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1021
    "Created: / 7.9.2001 / 13:37:06 / cg"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1022
    "Modified: / 7.9.2001 / 13:38:15 / cg"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1023
!
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1024
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1025
asFloatQ
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1026
    "return a quad precision float with same value.
21879
66122e220e92 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21865
diff changeset
  1027
     Notice that longFloats as returned here may or may not provide more
21940
4720e68ae2b4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 21935
diff changeset
  1028
     precision than a double - depending on the machine's CPU
4720e68ae2b4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 21935
diff changeset
  1029
     (and usually do not provide quad the number of bits of a float)    
5986
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1030
     Added for ANSI compatibility"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1031
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1032
   ^ self asLongFloat
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1033
21879
66122e220e92 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21865
diff changeset
  1034
    "Created: / 07-09-2001 / 13:38:44 / cg"
21940
4720e68ae2b4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 21935
diff changeset
  1035
    "Modified (comment): / 03-07-2017 / 10:19:13 / cg"
4720e68ae2b4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 21935
diff changeset
  1036
!
4720e68ae2b4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 21935
diff changeset
  1037
4720e68ae2b4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 21935
diff changeset
  1038
asFloatQD
4720e68ae2b4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 21935
diff changeset
  1039
    "return a quad double precision float with same value."
4720e68ae2b4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 21935
diff changeset
  1040
4720e68ae2b4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 21935
diff changeset
  1041
   ^ self asQDouble
4720e68ae2b4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 21935
diff changeset
  1042
4720e68ae2b4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 21935
diff changeset
  1043
    "Created: / 03-07-2017 / 10:19:41 / cg"
5986
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1044
!
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1045
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1046
asFraction
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1047
    "return a fraction with same value"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1048
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1049
   ^ self subclassResponsibility
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1050
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1051
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1052
asInteger
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1053
    "return an integer with same value - might truncate"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1054
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1055
    ^ self truncated
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1056
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1057
24279
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1058
asLargeFloat
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1059
    "return a largeFloat with same value"
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1060
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1061
    "WARNING: could loose precision here, if not redefined in concrete classes which
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1062
     have more than float precision (i.e. LargeIntegers and Fractions)"
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1063
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1064
    ^ self asFloat asLargeFloat "/ subclassResponsibility
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1065
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1066
    "Created: / 07-06-2019 / 02:32:57 / Claus Gittinger"
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1067
!
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1068
7378
e71a28f6b712 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7355
diff changeset
  1069
asLimitedPrecisionReal
e71a28f6b712 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7355
diff changeset
  1070
    "return a float of any precision with same value"
e71a28f6b712 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7355
diff changeset
  1071
e71a28f6b712 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7355
diff changeset
  1072
   ^ self asFloat
e71a28f6b712 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7355
diff changeset
  1073
!
e71a28f6b712 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7355
diff changeset
  1074
5986
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1075
asLongFloat
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1076
    "return a longFloat with same value"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1077
10315
4be6dacc89ce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9443
diff changeset
  1078
    "WARNING: could loose precision here, if not redefined in concrete classes which
4be6dacc89ce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9443
diff changeset
  1079
     have more than float precision (i.e. LargeIntegers and Fractions)"
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1080
10315
4be6dacc89ce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9443
diff changeset
  1081
    ^ self asFloat asLongFloat "/ subclassResponsibility
5986
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1082
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1083
    "Modified: / 17.4.1996 / 12:21:35 / cg"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1084
    "Created: / 7.9.2001 / 13:39:31 / cg"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1085
!
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
  1086
24279
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1087
asQuadFloat
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1088
    "return a quadFloat with same value"
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1089
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1090
    "WARNING: could loose precision here, if not redefined in concrete classes which
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1091
     have more than float precision (i.e. LargeIntegers and Fractions)"
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1092
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1093
    ^ self asFloat asQuadFloat "/ subclassResponsibility
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1094
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1095
    "Created: / 07-06-2019 / 02:28:54 / Claus Gittinger"
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1096
!
f02ac233eee7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24278
diff changeset
  1097
5987
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
  1098
asScaledDecimal:scale
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1099
    "return a fixedPoint approximating the receiver's value"
5987
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
  1100
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
  1101
    ^ self asFixedPoint:scale
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
  1102
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
  1103
    "
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
  1104
     1.234 asScaledDecimal:2
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
  1105
    "
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
  1106
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
  1107
    "Created: / 7.9.2001 / 13:46:26 / cg"
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
  1108
    "Modified: / 7.9.2001 / 13:46:44 / cg"
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
  1109
!
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
  1110
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1111
asShortFloat
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1112
    "return a shortFloat with same value"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1113
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1114
   ^ self asFloat asShortFloat
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1115
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1116
    "Modified: 17.4.1996 / 12:21:35 / cg"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1117
!
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1118
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1119
degreesToRadians
21106
c91208b4b28d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20696
diff changeset
  1120
    "interpreting the receiver as degrees, return the radians"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1121
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1122
    ^ self asFloat degreesToRadians
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1123
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1124
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1125
radiansToDegrees
21106
c91208b4b28d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20696
diff changeset
  1126
    "interpreting the receiver as radians, return the degrees"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1127
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1128
    ^ self asFloat radiansToDegrees
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1129
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1130
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1131
!ArithmeticValue methodsFor:'double dispatching'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1132
23499
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1133
bitAndFromInteger:anInteger
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1134
    "anInteger does not know how to do bitAnd: with the receiver -
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1135
     retry the operation by coercing to Integer"
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1136
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1137
    |selfAsInteger|
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1138
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1139
    selfAsInteger := self asInteger.
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1140
    self ~= selfAsInteger ifTrue:[
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1141
        DomainError raiseRequestErrorString:'non-integer mask in bit-operation'.
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1142
    ].
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1143
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1144
    ^ anInteger bitAnd:selfAsInteger
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1145
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1146
    "Created: / 01-11-2018 / 11:49:27 / Stefan Vogel"
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1147
!
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1148
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1149
bitOrFromInteger:anInteger
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1150
    "anInteger does not know how to do bitOr: with the receiver -
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1151
     retry the operation by coercing to Integer"
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1152
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1153
    |selfAsInteger|
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1154
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1155
    selfAsInteger := self asInteger.
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1156
    self ~= selfAsInteger ifTrue:[
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1157
        DomainError raiseRequestErrorString:'non-integer mask in bit-operation'.
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1158
    ].
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1159
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1160
    ^ anInteger bitOr:selfAsInteger
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1161
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1162
    "Created: / 01-11-2018 / 11:49:09 / Stefan Vogel"
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1163
!
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1164
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1165
bitXorFromInteger:anInteger
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1166
    "anInteger does not know how to do bitXor: with the receiver -
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1167
     retry the operation by coercing to Integer"
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1168
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1169
    |selfAsInteger|
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1170
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1171
    selfAsInteger := self asInteger.
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1172
    self ~= selfAsInteger ifTrue:[
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1173
        DomainError raiseRequestErrorString:'non-integer mask in bit-operation'.
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1174
    ].
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1175
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1176
    ^ anInteger bitXor:selfAsInteger
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1177
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1178
    "Created: / 01-11-2018 / 11:58:53 / Stefan Vogel"
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1179
!
6bdd727d4170 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23158
diff changeset
  1180
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1181
differenceFromComplex:aComplex
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1182
    "aComplex does not know how to subtract the receiver -
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1183
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1184
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1185
    ^ aComplex retry:#- coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1186
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1187
    "Modified (comment): / 12-06-2017 / 20:34:41 / cg"
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1188
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1189
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1190
differenceFromFixedPoint:aFixedPoint
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1191
    "aFixedPoint does not know how to subtract the receiver -
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1192
     retry the operation by coercing to higher generality"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1193
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1194
    ^ aFixedPoint retry:#- coercing:self
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1195
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1196
    "Created: / 05-11-1996 / 14:55:51 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1197
    "Modified (comment): / 12-06-2017 / 20:34:33 / cg"
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1198
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1199
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1200
differenceFromFloat:aFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1201
    "aFloat does not know how to subtract the receiver -
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1202
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1203
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1204
    ^ aFloat retry:#- coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1205
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1206
    "Modified (comment): / 12-06-2017 / 20:34:23 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1207
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1208
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1209
differenceFromFraction:aFraction
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1210
    "aFraction does not know how to subtract the receiver -
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1211
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1212
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1213
    ^ aFraction retry:#- coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1214
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1215
    "Modified (comment): / 12-06-2017 / 20:34:16 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1216
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1217
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1218
differenceFromInteger:anInteger
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1219
    "anInteger does not know how to subtract the receiver -
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1220
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1221
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1222
    ^ anInteger retry:#- coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1223
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1224
    "Modified (comment): / 12-06-2017 / 20:34:07 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1225
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1226
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1227
differenceFromLargeFloat:aLargeFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1228
    "aLargeFloat does not know how to subtract the receiver -
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1229
     retry the operation by coercing to higher generality"
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1230
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1231
    ^ aLargeFloat retry:#- coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1232
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1233
    "Modified (comment): / 12-06-2017 / 20:34:00 / cg"
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1234
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1235
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1236
differenceFromLongFloat:aLongFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1237
    "aLongFloat does not know how to subtract the receiver -
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1238
     retry the operation by coercing to higher generality"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1239
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1240
    ^ aLongFloat retry:#- coercing:self
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1241
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1242
    "Created: / 17-04-1996 / 12:33:16 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1243
    "Modified (comment): / 12-06-2017 / 20:33:50 / cg"
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1244
!
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1245
24278
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1246
differenceFromQuadFloat:aQuadFloat
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1247
    "aQuadFloat does not know how to subtract the receiver -
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1248
     retry the operation by coercing to higher generality"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1249
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1250
    ^ aQuadFloat retry:#- coercing:self
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1251
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1252
    "Created: / 07-06-2019 / 02:20:52 / Claus Gittinger"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1253
!
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1254
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1255
differenceFromShortFloat:aShortFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1256
    "aShortFloat does not know how to subtract the receiver -
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1257
     retry the operation by coercing to higher generality"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1258
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1259
    ^ aShortFloat retry:#- coercing:self
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1260
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1261
    "Created: / 17-04-1996 / 12:33:16 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1262
    "Modified (comment): / 12-06-2017 / 20:33:43 / cg"
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1263
!
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1264
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1265
equalFromComplex:aComplex
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1266
    "aComplex does not know how to compare to the receiver -
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1267
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1268
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1269
    ^ aComplex retry:#= coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1270
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1271
    "Modified (comment): / 12-06-2017 / 20:33:26 / cg"
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1272
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1273
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1274
equalFromFixedPoint:aFixedPoint
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1275
    "aFixedPoint does not know how to compare to the receiver -
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1276
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1277
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1278
    ^ aFixedPoint retry:#= coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1279
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1280
    "Modified (comment): / 12-06-2017 / 20:33:17 / cg"
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1281
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1282
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1283
equalFromFloat:aFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1284
    "aFloat does not know how to compare to the receiver -
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1285
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1286
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1287
    ^ aFloat retry:#= coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1288
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1289
    "Modified (comment): / 12-06-2017 / 20:33:09 / cg"
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1290
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1291
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1292
equalFromFraction:aFraction
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1293
    "aFraction does not know how to compare to the receiver -
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1294
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1295
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1296
    ^ aFraction retry:#= coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1297
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1298
    "Modified (comment): / 12-06-2017 / 20:33:01 / cg"
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1299
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1300
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1301
equalFromInteger:anInteger
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1302
    "anInteger does not know how to compare to the receiver -
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1303
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1304
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1305
    ^ anInteger retry:#= coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1306
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1307
    "Modified (comment): / 12-06-2017 / 20:32:53 / cg"
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1308
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1309
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1310
equalFromLargeFloat:aLargeFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1311
    "aLargeFloat does not know how to compare to the receiver -
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1312
     retry the operation by coercing to higher generality"
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1313
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1314
    ^ aLargeFloat retry:#= coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1315
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1316
    "Modified (comment): / 12-06-2017 / 20:32:45 / cg"
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1317
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1318
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1319
equalFromLongFloat:aLongFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1320
    "aLongFloat does not know how to compare to the receiver -
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1321
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1322
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1323
    ^ aLongFloat retry:#= coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1324
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1325
    "Modified (comment): / 12-06-2017 / 20:32:36 / cg"
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1326
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1327
24278
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1328
equalFromQuadFloat:aQuadFloat
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1329
    "aQuadFloat does not know how to compare to the receiver -
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1330
     retry the operation by coercing to higher generality"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1331
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1332
    ^ aQuadFloat retry:#= coercing:self
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1333
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1334
    "Created: / 07-06-2019 / 02:21:11 / Claus Gittinger"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1335
!
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1336
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1337
equalFromShortFloat:aShortFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1338
    "aShortFloat does not know how to compare to the receiver -
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1339
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1340
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1341
    ^ aShortFloat retry:#= coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1342
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1343
    "Modified (comment): / 12-06-2017 / 20:32:28 / cg"
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1344
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1345
13007
Claus Gittinger <cg@exept.de>
parents: 12980
diff changeset
  1346
integerQuotientFromInteger:anInteger
Claus Gittinger <cg@exept.de>
parents: 12980
diff changeset
  1347
    "anInteger does not know how to divide by the receiver -
Claus Gittinger <cg@exept.de>
parents: 12980
diff changeset
  1348
     retry the operation by coercing to higher generality"
Claus Gittinger <cg@exept.de>
parents: 12980
diff changeset
  1349
Claus Gittinger <cg@exept.de>
parents: 12980
diff changeset
  1350
    ^ anInteger retry:#// coercing:self
Claus Gittinger <cg@exept.de>
parents: 12980
diff changeset
  1351
Claus Gittinger <cg@exept.de>
parents: 12980
diff changeset
  1352
    "Created: / 09-08-2010 / 19:49:26 / cg"
Claus Gittinger <cg@exept.de>
parents: 12980
diff changeset
  1353
!
Claus Gittinger <cg@exept.de>
parents: 12980
diff changeset
  1354
16657
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
  1355
isAlmostEqualToFromFloat:aFloat nEpsilon:nE
24278
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1356
    "aFloat does not know how to compare to the receiver -
16657
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
  1357
     retry the operation by coercing to higher generality"
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
  1358
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
  1359
    ^ aFloat retry:#isAlmostEqualTo:nEpsilon: coercing:self with:nE
24278
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1360
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1361
    "Modified (comment): / 07-06-2019 / 02:23:00 / Claus Gittinger"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1362
!
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1363
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1364
isAlmostEqualToFromLargeFloat:aLargeFloat nEpsilon:nE
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1365
    "aLargeFloat does not know how to compare to the receiver -
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1366
     retry the operation by coercing to higher generality"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1367
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1368
    ^ aLargeFloat retry:#isAlmostEqualTo:nEpsilon: coercing:self with:nE
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1369
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1370
    "Created: / 07-06-2019 / 02:24:57 / Claus Gittinger"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1371
!
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1372
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1373
isAlmostEqualToFromLongFloat:aLongFloat nEpsilon:nE
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1374
    "aLongFloat does not know how to compare to the receiver -
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1375
     retry the operation by coercing to higher generality"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1376
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1377
    ^ aLongFloat retry:#isAlmostEqualTo:nEpsilon: coercing:self with:nE
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1378
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1379
    "Created: / 07-06-2019 / 02:22:01 / Claus Gittinger"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1380
!
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1381
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1382
isAlmostEqualToFromQuadFloat:aQuadFloat nEpsilon:nE
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1383
    "aQuadFloat does not know how to compare to the receiver -
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1384
     retry the operation by coercing to higher generality"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1385
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1386
    ^ aQuadFloat retry:#isAlmostEqualTo:nEpsilon: coercing:self with:nE
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1387
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1388
    "Created: / 07-06-2019 / 02:22:15 / Claus Gittinger"
16657
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
  1389
!
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
  1390
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
  1391
isAlmostEqualToFromShortFloat:aShortFloat nEpsilon:nE
24278
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1392
    "aShortFloat does not know how to compare to the receiver -
16657
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
  1393
     retry the operation by coercing to higher generality"
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
  1394
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
  1395
    ^ aShortFloat retry:#isAlmostEqualTo:nEpsilon: coercing:self with:nE
24278
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1396
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1397
    "Modified (comment): / 07-06-2019 / 02:23:25 / Claus Gittinger"
16657
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
  1398
!
a87789caf59d class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 16121
diff changeset
  1399
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1400
lessFromFixedPoint:aFixedPoint
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1401
    "aFixedPoint does not know how to compare to the receiver -
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1402
     Return true if aFixedPoint < self.
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1403
     retry the operation by coercing to higher generality"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1404
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1405
    ^ aFixedPoint retry:#< coercing:self
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1406
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1407
    "Created: / 05-11-1996 / 14:56:12 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1408
    "Modified (comment): / 12-06-2017 / 20:32:12 / cg"
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1409
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1410
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1411
lessFromFloat:aFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1412
    "aFloat does not know how to compare to the receiver -
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1413
     Return true if aFloat < self.
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1414
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1415
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1416
    ^ aFloat retry:#< coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1417
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1418
    "Modified (comment): / 12-06-2017 / 20:32:02 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1419
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1420
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1421
lessFromFraction:aFraction
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1422
    "aFraction does not know how to compare to the receiver -
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1423
     Return true if aFraction < self.
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1424
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1425
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1426
    ^ aFraction retry:#< coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1427
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1428
    "Modified (comment): / 12-06-2017 / 20:31:53 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1429
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1430
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1431
lessFromInteger:anInteger
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1432
    "anInteger does not know how to compare to the receiver -
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1433
     Return true if anInteger < self.
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1434
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1435
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1436
    ^ anInteger retry:#< coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1437
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1438
    "Modified (comment): / 12-06-2017 / 20:31:44 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1439
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1440
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1441
lessFromLargeFloat:aLargeFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1442
    "aLargeFloat does not know how to compare to the receiver -
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1443
     Return true if aLargeFloat < self.
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1444
     retry the operation by coercing to higher generality"
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1445
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1446
    ^ aLargeFloat retry:#< coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1447
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1448
    "Modified (comment): / 12-06-2017 / 20:31:36 / cg"
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1449
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1450
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1451
lessFromLongFloat:aLongFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1452
    "aLongFloat does not know how to compare to the receiver -
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1453
     Return true if aLongFloat < self.
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1454
     retry the operation by coercing to higher generality"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1455
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1456
    ^ aLongFloat retry:#< coercing:self
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1457
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1458
    "Modified: / 17-04-1996 / 12:33:33 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1459
    "Modified (comment): / 12-06-2017 / 20:31:28 / cg"
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1460
!
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1461
24278
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1462
lessFromQuadFloat:aQuadFloat
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1463
    "aQuadFloat does not know how to compare to the receiver -
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1464
     Return true if aQuadFloat < self.
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1465
     retry the operation by coercing to higher generality"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1466
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1467
    ^ aQuadFloat retry:#< coercing:self
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1468
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1469
    "Created: / 07-06-2019 / 02:23:41 / Claus Gittinger"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1470
!
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1471
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1472
lessFromShortFloat:aShortFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1473
    "aShortFloat does not know how to compare to the receiver -
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1474
     Return true if aShortFloat < self.
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1475
     retry the operation by coercing to higher generality"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1476
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1477
    ^ aShortFloat retry:#< coercing:self
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1478
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1479
    "Modified: / 17-04-1996 / 12:33:33 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1480
    "Modified (comment): / 12-06-2017 / 20:31:18 / cg"
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1481
!
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1482
14002
0f1ef36dc1b6 added: #moduloFromInteger:
Claus Gittinger <cg@exept.de>
parents: 14001
diff changeset
  1483
moduloFromInteger:anInteger
0f1ef36dc1b6 added: #moduloFromInteger:
Claus Gittinger <cg@exept.de>
parents: 14001
diff changeset
  1484
    "anInteger does not know how to compute the modulo from the receiver -
0f1ef36dc1b6 added: #moduloFromInteger:
Claus Gittinger <cg@exept.de>
parents: 14001
diff changeset
  1485
     retry the operation by coercing to higher generality"
0f1ef36dc1b6 added: #moduloFromInteger:
Claus Gittinger <cg@exept.de>
parents: 14001
diff changeset
  1486
0f1ef36dc1b6 added: #moduloFromInteger:
Claus Gittinger <cg@exept.de>
parents: 14001
diff changeset
  1487
    ^ anInteger retry:#\\ coercing:self
0f1ef36dc1b6 added: #moduloFromInteger:
Claus Gittinger <cg@exept.de>
parents: 14001
diff changeset
  1488
0f1ef36dc1b6 added: #moduloFromInteger:
Claus Gittinger <cg@exept.de>
parents: 14001
diff changeset
  1489
    "Created: / 12-02-2012 / 20:38:13 / cg"
0f1ef36dc1b6 added: #moduloFromInteger:
Claus Gittinger <cg@exept.de>
parents: 14001
diff changeset
  1490
!
0f1ef36dc1b6 added: #moduloFromInteger:
Claus Gittinger <cg@exept.de>
parents: 14001
diff changeset
  1491
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1492
productFromComplex:aComplex
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1493
    "aComplex does not know how to multiply the receiver -
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1494
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1495
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1496
    ^ aComplex retry:#* coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1497
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1498
    "Modified (comment): / 12-06-2017 / 20:31:06 / cg"
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1499
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1500
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1501
productFromFixedPoint:aFixedPoint
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1502
    "aFixedPoint does not know how to multiply the receiver -
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1503
     retry the operation by coercing to higher generality"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1504
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1505
    ^ aFixedPoint retry:#* coercing:self
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1506
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1507
    "Created: / 05-11-1996 / 14:56:28 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1508
    "Modified (comment): / 12-06-2017 / 20:30:56 / cg"
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1509
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1510
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1511
productFromFloat:aFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1512
    "aFloat does not know how to multiply the receiver -
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1513
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1514
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1515
    ^ aFloat retry:#* coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1516
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1517
    "Modified (comment): / 12-06-2017 / 20:30:46 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1518
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1519
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1520
productFromFraction:aFraction
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1521
    "aFraction does not know how to multiply the receiver -
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1522
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1523
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1524
    ^ aFraction retry:#* coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1525
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1526
    "Modified (comment): / 12-06-2017 / 20:30:38 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1527
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1528
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1529
productFromInteger:anInteger
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1530
    "anInteger does not know how to multiply the receiver -
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1531
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1532
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1533
    ^ anInteger retry:#* coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1534
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1535
    "Modified (comment): / 12-06-2017 / 20:29:21 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1536
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1537
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1538
productFromLargeFloat:aLargeFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1539
    "aLargeFloat does not know how to multiply the receiver -
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1540
     retry the operation by coercing to higher generality"
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1541
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1542
    ^ aLargeFloat retry:#* coercing:self
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1543
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1544
    "Created: / 17-04-1996 / 12:33:48 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1545
    "Modified (comment): / 12-06-2017 / 20:29:13 / cg"
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1546
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1547
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1548
productFromLongFloat:aLongFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1549
    "aLongFloat does not know how to multiply the receiver -
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1550
     retry the operation by coercing to higher generality"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1551
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1552
    ^ aLongFloat retry:#* coercing:self
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1553
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1554
    "Created: / 17-04-1996 / 12:33:48 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1555
    "Modified (comment): / 12-06-2017 / 20:29:05 / cg"
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1556
!
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1557
24278
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1558
productFromQuadFloat:aQuadFloat
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1559
    "aQuadFloat does not know how to multiply the receiver -
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1560
     retry the operation by coercing to higher generality"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1561
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1562
    ^ aQuadFloat retry:#* coercing:self
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1563
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1564
    "Created: / 07-06-2019 / 02:24:05 / Claus Gittinger"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1565
!
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1566
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1567
productFromShortFloat:aShortFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1568
    "aShortFloat does not know how to multiply the receiver -
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1569
     retry the operation by coercing to higher generality"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1570
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1571
    ^ aShortFloat retry:#* coercing:self
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1572
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1573
    "Created: / 17-04-1996 / 12:33:48 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1574
    "Modified (comment): / 12-06-2017 / 20:28:56 / cg"
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1575
!
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1576
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1577
quotientFromComplex:aComplex
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1578
    "aComplex does not know how to divide by the receiver -
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1579
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1580
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1581
    ^ aComplex retry:#/ coercing:self
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1582
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1583
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1584
quotientFromFixedPoint:aFixedPoint
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1585
    "aFixedPoint does not know how to divide by the receiver -
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1586
     retry the operation by coercing to higher generality"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1587
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1588
    ^ aFixedPoint retry:#/ coercing:self
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1589
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1590
    "Created: 5.11.1996 / 14:56:41 / cg"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1591
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1592
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1593
quotientFromFloat:aFloat
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1594
    "aFloat does not know how to divide by the receiver -
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1595
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1596
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1597
    ^ aFloat retry:#/ coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1598
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1599
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1600
quotientFromFraction:aFraction
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1601
    "aFraction does not know how to divide by the receiver -
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1602
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1603
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1604
    ^ aFraction retry:#/ coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1605
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1606
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1607
quotientFromInteger:aQDouble
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1608
    "aQDouble does not know how to divide by the receiver -
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1609
     retry the operation by coercing to higher generality"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1610
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1611
    ^ aQDouble retry:#/ coercing:self
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1612
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1613
    "Modified (comment): / 12-06-2017 / 20:35:45 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1614
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1615
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1616
quotientFromLargeFloat:aLargeFloat
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1617
    "aLargeFloat does not know how to divide by the receiver -
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1618
     retry the operation by coercing to higher generality"
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1619
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1620
    ^ aLargeFloat retry:#/ coercing:self
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1621
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1622
    "Created: 17.4.1996 / 12:34:00 / cg"
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1623
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1624
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1625
quotientFromLongFloat:aLongFloat
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1626
    "aLongFloat does not know how to divide by the receiver -
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1627
     retry the operation by coercing to higher generality"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1628
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1629
    ^ aLongFloat retry:#/ coercing:self
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1630
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1631
    "Created: 17.4.1996 / 12:34:00 / cg"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1632
!
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1633
24278
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1634
quotientFromQuadFloat:aQuadFloat
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1635
    "aQuadFloat does not know how to divide by the receiver -
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1636
     retry the operation by coercing to higher generality"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1637
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1638
    ^ aQuadFloat retry:#/ coercing:self
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1639
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1640
    "Created: / 07-06-2019 / 02:25:19 / Claus Gittinger"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1641
!
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1642
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1643
quotientFromShortFloat:aShortFloat
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1644
    "aShortFloat does not know how to divide by the receiver -
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1645
     retry the operation by coercing to higher generality"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1646
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1647
    ^ aShortFloat retry:#/ coercing:self
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1648
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1649
    "Created: 17.4.1996 / 12:34:00 / cg"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1650
!
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1651
21935
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1652
raisedFromFloat:aFloat
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1653
    "aFloat does not know how to be raised to the receiver"
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1654
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1655
    self isNumber ifTrue:[
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1656
        self isFloat ifFalse:[
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1657
            ^ self asFloat raisedFromFloat:aFloat
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1658
        ].
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1659
    ].
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1660
    ^ self raisedFromNumber:aFloat
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1661
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1662
    "Created: / 01-07-2017 / 21:18:54 / cg"
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1663
    "Modified: / 02-07-2017 / 00:44:47 / cg"
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1664
!
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1665
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1666
raisedFromNumber:aNumber
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
  1667
    "aNumber does not know how to be raised to the receiver 
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
  1668
     (i.e. how to compute aNumber^self)"
21935
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1669
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1670
    ^ self class
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1671
        raise:#domainErrorSignal
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1672
        receiver:aNumber
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1673
        selector:#raisedTo:
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1674
        arguments:(Array with:self)
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1675
        errorString:'bad receiver/arg in raisedTo:'
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1676
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1677
    "Created: / 01-07-2017 / 21:17:06 / cg"
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
  1678
    "Modified (comment): / 03-07-2017 / 14:06:53 / cg"
21935
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1679
!
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1680
14747
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1681
remainderFromFloat:aFloat
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1682
    "aFloat does not know how to compute the remainder with the receiver -
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1683
     retry the operation by coercing to higher generality"
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1684
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1685
    ^ aFloat retry:#rem: coercing:self
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1686
!
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1687
24278
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1688
remainderFromLargeFloat:aLargeFloat
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1689
    "aLargeFloat does not know how to compute the remainder with the receiver -
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1690
     retry the operation by coercing to higher generality"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1691
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1692
    ^ aLargeFloat retry:#rem: coercing:self
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1693
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1694
    "Created: / 07-06-2019 / 02:25:57 / Claus Gittinger"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1695
!
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1696
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1697
remainderFromLongFloat:aLongFloat
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1698
    "aLongFloat does not know how to compute the remainder with the receiver -
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1699
     retry the operation by coercing to higher generality"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1700
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1701
    ^ aLongFloat retry:#rem: coercing:self
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1702
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1703
    "Created: / 07-06-2019 / 02:25:43 / Claus Gittinger"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1704
!
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1705
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1706
remainderFromQuadFloat:aQuadFloat
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1707
    "aQuadFloat does not know how to compute the remainder with the receiver -
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1708
     retry the operation by coercing to higher generality"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1709
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1710
    ^ aQuadFloat retry:#rem: coercing:self
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1711
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1712
    "Created: / 07-06-2019 / 02:26:08 / Claus Gittinger"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1713
!
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1714
14747
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1715
remainderFromShortFloat:aShortFloat
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1716
    "aShortFloat does not know how to compute the remainder with the receiver -
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1717
     retry the operation by coercing to higher generality"
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1718
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1719
    ^ aShortFloat retry:#rem: coercing:self
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1720
!
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  1721
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1722
sumFromComplex:aComplex
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1723
    "aComplex does not know how to add the receiver -
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1724
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1725
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1726
    ^ aComplex retry:#+ coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1727
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1728
    "Modified (comment): / 12-06-2017 / 20:27:25 / cg"
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1729
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1730
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1731
sumFromFixedPoint:aFixedPoint
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1732
    "aFixedPoint does not know how to add the receiver -
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1733
     retry the operation by coercing to higher generality"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1734
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1735
    ^ aFixedPoint retry:#+ coercing:self
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1736
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1737
    "Created: / 05-11-1996 / 14:56:56 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1738
    "Modified (comment): / 12-06-2017 / 20:27:38 / cg"
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1739
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
  1740
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1741
sumFromFloat:aFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1742
    "aFloat does not know how to add the receiver -
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1743
     retry the operation by coercing to higher generality"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1744
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1745
    ^ aFloat retry:#+ coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1746
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1747
    "Modified (comment): / 12-06-2017 / 20:27:47 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1748
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1749
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1750
sumFromFraction:aFraction
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1751
    "aFraction does not know how to add the receiver -
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1752
     retry the operation by coercing to higher generality"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1753
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1754
    ^ aFraction retry:#+ coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1755
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1756
    "Modified (comment): / 12-06-2017 / 20:27:55 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1757
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1758
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1759
sumFromInteger:anInteger
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1760
    "anInteger does not know how to add the receiver -
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1761
     retry the operation by coercing to higher generality"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1762
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1763
    ^ anInteger retry:#+ coercing:self
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1764
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1765
    "Modified (comment): / 12-06-2017 / 20:28:03 / cg"
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1766
!
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1767
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1768
sumFromLargeFloat:aLargeFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1769
    "aLargeFloat does not know how to add the receiver -
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1770
     retry the operation by coercing to higher generality"
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1771
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1772
    ^ aLargeFloat retry:#+ coercing:self
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1773
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1774
    "Created: / 17-04-1996 / 12:34:10 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1775
    "Modified (comment): / 12-06-2017 / 20:28:11 / cg"
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1776
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  1777
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1778
sumFromLongFloat:aLongFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1779
    "aLongFloat does not know how to add the receiver -
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1780
     retry the operation by coercing to higher generality"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1781
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1782
    ^ aLongFloat retry:#+ coercing:self
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1783
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1784
    "Created: / 17-04-1996 / 12:34:10 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1785
    "Modified (comment): / 12-06-2017 / 20:28:19 / cg"
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1786
!
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1787
24278
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1788
sumFromQuadFloat:aQuadFloat
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1789
    "aQuadFloat does not know how to add the receiver -
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1790
     retry the operation by coercing to higher generality"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1791
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1792
    ^ aQuadFloat retry:#+ coercing:self
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1793
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1794
    "Created: / 07-06-2019 / 02:26:36 / Claus Gittinger"
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1795
!
00a52d472419 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24274
diff changeset
  1796
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1797
sumFromShortFloat:aShortFloat
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1798
    "aShortFloat does not know how to add the receiver -
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1799
     retry the operation by coercing to higher generality"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1800
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1801
    ^ aShortFloat retry:#+ coercing:self
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
  1802
21797
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1803
    "Created: / 17-04-1996 / 12:34:10 / cg"
770933d4f13a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21106
diff changeset
  1804
    "Modified (comment): / 12-06-2017 / 20:28:39 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1805
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1806
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1807
!ArithmeticValue methodsFor:'mathematical functions'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1808
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  1809
** aNumber
9443
5d3f32a6f43e added **
Claus Gittinger <cg@exept.de>
parents: 9400
diff changeset
  1810
    "Answer the receiver raised to the power of the argument, aNumber."
5d3f32a6f43e added **
Claus Gittinger <cg@exept.de>
parents: 9400
diff changeset
  1811
    "same as Number>>raisedTo:"
5d3f32a6f43e added **
Claus Gittinger <cg@exept.de>
parents: 9400
diff changeset
  1812
5d3f32a6f43e added **
Claus Gittinger <cg@exept.de>
parents: 9400
diff changeset
  1813
    ^self raisedTo: aNumber
5d3f32a6f43e added **
Claus Gittinger <cg@exept.de>
parents: 9400
diff changeset
  1814
5d3f32a6f43e added **
Claus Gittinger <cg@exept.de>
parents: 9400
diff changeset
  1815
    "Created: / 15-07-2006 / 15:11:05 / cg"
5d3f32a6f43e added **
Claus Gittinger <cg@exept.de>
parents: 9400
diff changeset
  1816
    "Modified: / 17-07-2006 / 12:51:33 / cg"
5d3f32a6f43e added **
Claus Gittinger <cg@exept.de>
parents: 9400
diff changeset
  1817
!
5d3f32a6f43e added **
Claus Gittinger <cg@exept.de>
parents: 9400
diff changeset
  1818
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1819
basicRaisedToInteger:exp
21804
92c5bbb60712 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21797
diff changeset
  1820
    "return the receiver raised to exp.
92c5bbb60712 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21797
diff changeset
  1821
     Warning: if the receiver is a float/double, 
92c5bbb60712 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21797
diff changeset
  1822
     currently INF may be returned on overflow. 
92c5bbb60712 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21797
diff changeset
  1823
     This may be changed silently to raise an error in future versions."
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1824
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1825
    |result e t|
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1826
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1827
    "use the addition chaining algorithm,
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1828
     which is much faster for big exponents"
6858
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1829
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1830
    result := 1.
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1831
    t := self.
24956
dc04e2668278 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24861
diff changeset
  1832
    (e := exp) < 0 ifTrue:[
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1833
        e := exp negated.
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1834
    ].
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1835
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1836
    [e ~~ 0] whileTrue:[
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1837
        [(e bitAnd:1) == 0] whileTrue:[
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1838
            e := e bitShift:-1.
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1839
            t := t * t.
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1840
        ].
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1841
        e := e - 1.
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1842
        result := result * t.
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1843
    ].
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1844
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1845
    (exp < 0) ifTrue:[
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1846
        ^ 1 / result
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1847
    ].
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1848
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1849
    ^ result
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1850
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1851
    "
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1852
     (2 raisedToInteger:216)
24956
dc04e2668278 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24861
diff changeset
  1853
     (2.0 raisedToInteger:216)  
dc04e2668278 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24861
diff changeset
  1854
     (2.0 asLongFloat) raisedToInteger:216
dc04e2668278 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24861
diff changeset
  1855
     (2.0 asShortFloat) raisedToInteger:216
dc04e2668278 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24861
diff changeset
  1856
     (2.0 asQDouble) raisedToInteger:216
dc04e2668278 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24861
diff changeset
  1857
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1858
     (2 raisedTo:216)
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1859
            -> 105312291668557186697918027683670432318895095400549111254310977536
24956
dc04e2668278 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24861
diff changeset
  1860
     (2.0 raisedToInteger:216) asInteger - (2 raisedToInteger:216) 
dc04e2668278 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24861
diff changeset
  1861
     (2.0 raisedToInteger:400) asInteger - (2 raisedToInteger:400) 
dc04e2668278 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24861
diff changeset
  1862
     (2.0 raisedToInteger:500) asInteger - (2 raisedToInteger:500)  
dc04e2668278 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24861
diff changeset
  1863
     (2.0 raisedToInteger:1000) asInteger - (2 raisedToInteger:1000)  
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1864
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1865
     (2 raisedToInteger:216) asFloat
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1866
     (2 raisedTo:216) asFloat
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1867
            -> 1.05312E+65
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1868
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1869
     (2 raisedToInteger:500)
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1870
     (2 raisedTo:500)
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1871
            -> 3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1872
     (2 raisedTo:-500)
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1873
            -> (1/3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376)
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1874
     2 raisedToInteger:10
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1875
            -> 1024
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1876
    -2 raisedToInteger:10
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1877
            -> 1024
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1878
     -2 raisedToInteger:9
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1879
            -> -512
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1880
     10 raisedToInteger:-10
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1881
            -> (1/10000000000)
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1882
     2 raisedToInteger:0
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1883
            -> 1
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1884
     2 raisedToInteger:-1
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1885
            -> (1/2)
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1886
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1887
     Time millisecondsToRun:[
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1888
        10000 timesRepeat:[
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1889
            (2 raisedToInteger:500)
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1890
        ]
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1891
     ]
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1892
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1893
     Time millisecondsToRun:[
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1894
        |bigNum|
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1895
        bigNum := 2 raisedToInteger:500.
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1896
        10 timesRepeat:[
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1897
            (bigNum raisedToInteger:500)
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1898
        ]
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1899
     ]
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1900
    "
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1901
21804
92c5bbb60712 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21797
diff changeset
  1902
    "Created: / 27-04-1999 / 15:19:22 / stefan"
92c5bbb60712 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21797
diff changeset
  1903
    "Modified (comment): / 13-06-2017 / 17:35:41 / cg"
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1904
!
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  1905
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1906
raisedTo: aNumber
21935
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1907
    "return the receiver raised to aNumber (i.e. self ^ aNumber)"
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1908
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1909
    aNumber isInteger ifTrue:[
21935
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1910
        ^ self raisedToInteger:aNumber
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1911
    ].
23158
1d6551c846d0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22731
diff changeset
  1912
    self raisedFromNumber:aNumber.      "/ this raises an error.
21935
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1913
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1914
    "
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1915
     2 raisedTo:16
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1916
     2.0 raisedTo:16
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1917
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1918
     3 raisedTo:4
23158
1d6551c846d0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22731
diff changeset
  1919
     10@10 raisedTo:4
1d6551c846d0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22731
diff changeset
  1920
     10@10 raisedTo:4.0
21935
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1921
    "
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1922
93150e33d131 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21879
diff changeset
  1923
    "Modified (format): / 01-07-2017 / 20:59:35 / cg"
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1924
!
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1925
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1926
raisedToInteger:exp
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1927
    "return the receiver raised to exp.
21804
92c5bbb60712 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21797
diff changeset
  1928
     Warning: if the receiver is a float/double, 
92c5bbb60712 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21797
diff changeset
  1929
     currently INF may be returned on overflow. 
92c5bbb60712 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21797
diff changeset
  1930
     This may be changed silently to raise an error in future versions."
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1931
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1932
    ^ self basicRaisedToInteger:exp
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1933
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1934
    "
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1935
     (2.0 raisedToInteger:10000)
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1936
     (2 raisedToInteger:10000)
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1937
     (2 raisedToInteger:-10000)
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  1938
17662
0fd098ccf3ff class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 17336
diff changeset
  1939
     (2.0 raisedToInteger:216)
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1940
     (2 raisedToInteger:216)
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  1941
     (2 raisedTo:216)
12760
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1942
            -> 105312291668557186697918027683670432318895095400549111254310977536
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1943
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  1944
     (2 raisedToInteger:216) asFloat
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  1945
     (2 raisedTo:216) asFloat
12760
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1946
            -> 1.05312E+65
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1947
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1948
     (2 raisedToInteger:500)
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  1949
     (2 raisedTo:500)
12760
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1950
            -> 3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  1951
     2 raisedToInteger:10
12760
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1952
            -> 1024
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1953
    -2 raisedToInteger:10
12760
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1954
            -> 1024
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1955
     -2 raisedToInteger:9
12760
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1956
            -> -512
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1957
     10 raisedToInteger:-10
12760
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1958
            -> (1/10000000000)
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  1959
     2 raisedToInteger:0
12760
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1960
            -> 1
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  1961
     2 raisedToInteger:-1
12760
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1962
            -> (1/2)
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1963
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1964
     Time millisecondsToRun:[
12760
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1965
        10000 timesRepeat:[
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1966
            (2 raisedToInteger:500)
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1967
        ]
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  1968
     ]
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1969
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1970
     Time millisecondsToRun:[
12760
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1971
        |bigNum|
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1972
        bigNum := 2 raisedToInteger:500.
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1973
        10 timesRepeat:[
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1974
            (bigNum raisedToInteger:500)
6482afd031af comment/format in: #raisedToInteger:
Claus Gittinger <cg@exept.de>
parents: 12578
diff changeset
  1975
        ]
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1976
     ]
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1977
    "
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1978
21804
92c5bbb60712 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21797
diff changeset
  1979
    "Created: / 27-04-1999 / 15:19:22 / stefan"
92c5bbb60712 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21797
diff changeset
  1980
    "Modified (comment): / 13-06-2017 / 17:35:20 / cg"
8633
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1981
!
239f2bd03afe raisedTo: / raisedToInteger: moved up
Claus Gittinger <cg@exept.de>
parents: 8449
diff changeset
  1982
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1983
squared
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1984
    "return receiver * receiver"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1985
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1986
    ^ self * self
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1987
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1988
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1989
!ArithmeticValue methodsFor:'queries'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1990
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1991
respondsToArithmetic
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1992
    "return true, if the receiver responds to arithmetic messages"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1993
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1994
    ^ true
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1995
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1996
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1997
!ArithmeticValue methodsFor:'testing'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1998
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1999
denominator
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2000
    "return the denominator of the receiver"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2001
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2002
    ^ 1
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2003
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2004
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2005
even
17223
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
  2006
    "return true if the receiver is divisible by 2.
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
  2007
     This is only defined for whole-numbers (integers)."
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2008
17223
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
  2009
    ^ self class
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
  2010
        raise:#domainErrorSignal
17223
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
  2011
        receiver:self
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
  2012
        selector:#even
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
  2013
        arguments:#()
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
  2014
        errorString:'Receiver must be a whole-number'
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
  2015
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
  2016
    "/ No no no, the following is bad: 
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
  2017
    "/      ^ self truncated asInteger even
17223
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
  2018
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
  2019
    "
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
  2020
     2.4 even
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
  2021
     2.0 even
17223
db522b3aff6f class: ArithmeticValue
Stefan Vogel <sv@exept.de>
parents: 17222
diff changeset
  2022
    "
21967
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
  2023
0a6e9e6e26f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21940
diff changeset
  2024
    "Modified (comment): / 03-07-2017 / 14:10:01 / cg"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2025
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2026
3635
3fcccef48db3 complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3393
diff changeset
  2027
isComplex
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  2028
    "Answer whether the receiver has an imaginary part
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  2029
     (i.e. if it is a complex number). Always false here."
3635
3fcccef48db3 complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3393
diff changeset
  2030
3fcccef48db3 complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3393
diff changeset
  2031
    ^ false
3fcccef48db3 complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3393
diff changeset
  2032
3fcccef48db3 complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3393
diff changeset
  2033
    "Modified: / 9.7.1998 / 10:19:27 / cg"
3fcccef48db3 complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3393
diff changeset
  2034
!
3fcccef48db3 complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3393
diff changeset
  2035
8979
869510c58b9c Move #isFinite and #isInfinite from Number to ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8892
diff changeset
  2036
isFinite
24711
e821bbd154fa #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24301
diff changeset
  2037
    "return true, if the receiver is finite (not NaN and not +/-INF)
9400
e3d6f81078ce comment
Stefan Vogel <sv@exept.de>
parents: 8979
diff changeset
  2038
     i.e. it can be represented as a rational number."
e3d6f81078ce comment
Stefan Vogel <sv@exept.de>
parents: 8979
diff changeset
  2039
8979
869510c58b9c Move #isFinite and #isInfinite from Number to ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8892
diff changeset
  2040
    ^ true
869510c58b9c Move #isFinite and #isInfinite from Number to ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8892
diff changeset
  2041
!
869510c58b9c Move #isFinite and #isInfinite from Number to ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8892
diff changeset
  2042
869510c58b9c Move #isFinite and #isInfinite from Number to ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8892
diff changeset
  2043
isInfinite
24711
e821bbd154fa #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24301
diff changeset
  2044
    "return true, if the receiver is an infinite number (+Inf or -Inf)"
e821bbd154fa #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24301
diff changeset
  2045
8979
869510c58b9c Move #isFinite and #isInfinite from Number to ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8892
diff changeset
  2046
    ^ false
869510c58b9c Move #isFinite and #isInfinite from Number to ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8892
diff changeset
  2047
!
869510c58b9c Move #isFinite and #isInfinite from Number to ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8892
diff changeset
  2048
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2049
isNegativeInfinity
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2050
    ^ self negative and:[self isInfinite]
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2051
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2052
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2053
isNegativeZero
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2054
    "return false - must be redefined by subclasses which can represent a negative zero
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2055
     (i.e. limitedPrecisionReal classes)"
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2056
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2057
    ^ false
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2058
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2059
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2060
isPositiveInfinity
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2061
    ^ self positive and:[self isInfinite]
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2062
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2063
6156
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  2064
isReal
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  2065
    "return true, if the receiver is some kind of real number (as opposed to a complex);
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  2066
     false is returned here - the method is only redefined in Number (and Complex)."
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  2067
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  2068
    ^ false
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  2069
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  2070
    "Modified: / 6.11.2001 / 13:20:20 / cg"
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  2071
    "Created: / 6.11.2001 / 13:26:29 / cg"
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  2072
!
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  2073
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2074
isZero
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2075
    "return false - must be redefined by subclasses which can represent a negative zero
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2076
     (i.e. limitedPrecisionReal classes)"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2077
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2078
    ^ self = self class zero
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2079
!
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2080
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2081
negative
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  2082
    "return true if the receiver is less than zero."
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2083
8202
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
  2084
    ^ self < self class zero
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2085
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2086
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2087
numerator
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2088
    "return the numerator of the receiver."
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2089
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2090
    ^ self
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2091
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2092
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2093
odd
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2094
    "return true if the receiver is not divisible by 2"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2095
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2096
    ^ self even not
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2097
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2098
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2099
positive
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  2100
    "return true, if the receiver is greater or equal to zero (not negative)"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2101
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2102
    ^ self negative not
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2103
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2104
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2105
sign
7471
c5d4bd612d9f comments
Claus Gittinger <cg@exept.de>
parents: 7468
diff changeset
  2106
    "return the sign of the receiver (-1, 0 or 1)"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2107
7440
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2108
    |zero|
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2109
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2110
    zero := self class zero.
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2111
    (self < zero) ifTrue:[^ -1].
d96bfc80e75e double dispatching
Claus Gittinger <cg@exept.de>
parents: 7429
diff changeset
  2112
    (zero < self) ifTrue:[^ 1].
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2113
    ^ 0
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2114
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2115
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2116
strictlyPositive
18860
fb68af2a33a9 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18844
diff changeset
  2117
    "return true, if the receiver is greater than zero"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2118
8202
2a6c8d1e26cb Define #asFixedPoint in ArithmethicValue
Stefan Vogel <sv@exept.de>
parents: 8184
diff changeset
  2119
    ^ self class zero < self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2120
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2121
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2122
!ArithmeticValue methodsFor:'truncation & rounding'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2123
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2124
ceiling
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2125
    "return the integer nearest the receiver towards positive infinity."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2126
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2127
    |anInteger|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2128
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2129
    anInteger := self // 1.       "truncates towards negative infinity"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2130
    anInteger = self ifTrue:[^ anInteger].
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2131
    ^ anInteger + 1
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2132
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2133
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2134
floor
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2135
    "return the receiver truncated towards negative infinity"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2136
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2137
    ^ self // 1
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2138
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2139
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2140
roundTo:aNumber
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2141
    "return the receiver rounded to multiples of aNumber"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2142
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2143
    ^ (self / aNumber) rounded * aNumber
8449
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2144
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2145
    "
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  2146
     0 roundTo:4
8449
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2147
     1 roundTo:4
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2148
     2 roundTo:4
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2149
     3 roundTo:4
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2150
     4 roundTo:4
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2151
     5 roundTo:4
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2152
     6 roundTo:4
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2153
     7 roundTo:4
14497
211259d933cb class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14002
diff changeset
  2154
24861
68e1f568f097 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24711
diff changeset
  2155
     1.15 roundTo:0.1  
68e1f568f097 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24711
diff changeset
  2156
     1.14 roundTo:0.1  
68e1f568f097 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24711
diff changeset
  2157
68e1f568f097 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24711
diff changeset
  2158
     7.15 roundTo:0.1  
68e1f568f097 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24711
diff changeset
  2159
     7.149 roundTo:0.1  
68e1f568f097 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24711
diff changeset
  2160
14497
211259d933cb class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14002
diff changeset
  2161
     7.123 roundTo:0.1
211259d933cb class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14002
diff changeset
  2162
     7.523 roundTo:0.1
211259d933cb class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14002
diff changeset
  2163
     7.583 roundTo:0.1 
211259d933cb class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14002
diff changeset
  2164
     7.623 roundTo:0.1
211259d933cb class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14002
diff changeset
  2165
     7.623 roundTo:0.01 
211259d933cb class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14002
diff changeset
  2166
     7.628 roundTo:0.01 
8449
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2167
    "
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2168
!
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2169
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2170
roundUpTo:aNumber
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2171
    "return the receiver rounded up to the next multiple of aNumber"
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2172
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2173
    ^ (self / aNumber) ceiling * aNumber
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2174
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2175
    "
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  2176
     0 roundUpTo:4
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  2177
     1 roundUpTo:4
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  2178
     2 roundUpTo:4
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  2179
     3 roundUpTo:4
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  2180
     4 roundUpTo:4
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  2181
     5 roundUpTo:4
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  2182
     6 roundUpTo:4
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  2183
     7 roundUpTo:4
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  2184
     8 roundUpTo:4
10911
38e7677d10a7 comment added
Claus Gittinger <cg@exept.de>
parents: 10326
diff changeset
  2185
     (3@4) roundUpTo:8
38e7677d10a7 comment added
Claus Gittinger <cg@exept.de>
parents: 10326
diff changeset
  2186
     (3@4) roundUpTo:(5 @ 4)
38e7677d10a7 comment added
Claus Gittinger <cg@exept.de>
parents: 10326
diff changeset
  2187
     (3@3) roundUpTo:(5 @ 4) 
8449
9ec3ade5a78b +roundUpTo
Claus Gittinger <cg@exept.de>
parents: 8202
diff changeset
  2188
    "
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2189
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2190
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2191
rounded
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2192
    "return the integer nearest the receiver"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2193
1881
0c6ba2c134c1 fixed #rounded
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
  2194
    self negative ifTrue:[
10326
b1103ad3581f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10324
diff changeset
  2195
	^ (self - 0.5) ceiling
1881
0c6ba2c134c1 fixed #rounded
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
  2196
    ].
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2197
    ^ (self + 0.5) floor
1881
0c6ba2c134c1 fixed #rounded
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
  2198
0c6ba2c134c1 fixed #rounded
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
  2199
    "Modified: 5.11.1996 / 11:31:59 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2200
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2201
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2202
truncateTo:aNumber
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2203
    "return the receiver truncated to multiples of aNumber"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2204
19056
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2205
    |t|
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2206
    
24274
f3a6d4988c82 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23645
diff changeset
  2207
    aNumber <= 0 ifTrue:[ArgumentError raiseErrorString:'argument must be positive'].
19056
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2208
    
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2209
    t := (self / aNumber) floor * aNumber.
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2210
    (aNumber isInteger) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2211
        ^ t asInteger
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2212
    ].    
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2213
    ^ t
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2214
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2215
    "
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2216
     truncate to multiples of 4 
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2217
        123.456 truncateTo:4
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2218
        124.456 truncateTo:4
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2219
     truncate to multiples of 2 
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2220
        122.456 truncateTo:2
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2221
        123.456 truncateTo:2
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2222
        124.456 truncateTo:2
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2223
     normal truncate
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2224
        123.456 truncateTo:1
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2225
        124.456 truncateTo:1
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2226
     truncate to decimal digits    
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2227
        123.456 truncateTo:0.1
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2228
        123.987 truncateTo:0.1
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2229
        123.456 truncateTo:0.01
Claus Gittinger <cg@exept.de>
parents: 18860
diff changeset
  2230
    "
24274
f3a6d4988c82 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23645
diff changeset
  2231
f3a6d4988c82 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23645
diff changeset
  2232
    "Modified: / 06-06-2019 / 23:27:55 / Claus Gittinger"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2233
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2234
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2235
truncated
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2236
    "return the receiver truncated towards zero"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2237
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2238
    self negative ifTrue:[
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2239
	^ self ceiling
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2240
    ].
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2241
    ^ self floor
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2242
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2243
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2244
!ArithmeticValue class methodsFor:'documentation'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2245
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2246
version
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  2247
    ^ '$Header$'
12576
47985f127034 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 11735
diff changeset
  2248
!
47985f127034 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 11735
diff changeset
  2249
47985f127034 category of:6 methods
Claus Gittinger <cg@exept.de>
parents: 11735
diff changeset
  2250
version_CVS
18835
c3bc89761fa4 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17662
diff changeset
  2251
    ^ '$Header$'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2252
! !
6858
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  2253
14747
18be9a3c2324 class: ArithmeticValue
Claus Gittinger <cg@exept.de>
parents: 14497
diff changeset
  2254
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2255
ArithmeticValue initialize!