ArithmeticValue.st
author Claus Gittinger <cg@exept.de>
Wed, 18 Jun 2003 00:45:36 +0200
changeset 7416 4ca9990e4e74
parent 7412 daae29634e02
child 7429 3efb092371a3
permissions -rw-r--r--
*** empty log message ***
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
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
5948
1fc30f692713 new class based exceptions
Claus Gittinger <cg@exept.de>
parents: 5238
diff changeset
    13
"{ Package: 'stx:libbasic' }"
1fc30f692713 new class based exceptions
Claus Gittinger <cg@exept.de>
parents: 5238
diff changeset
    14
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    15
Magnitude subclass:#ArithmeticValue
1172
b135d4ae4bf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    16
	instanceVariableNames:''
b135d4ae4bf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    17
	classVariableNames:'DivisionByZeroSignal DomainErrorSignal OverflowSignal
6342
fbbe62d5b17c Remove obsolete (since years) AnyArithmeticSignal definitions.
Stefan Vogel <sv@exept.de>
parents: 6156
diff changeset
    18
		UnderflowSignal ArithmeticSignal UnorderedSignal
fbbe62d5b17c Remove obsolete (since years) AnyArithmeticSignal definitions.
Stefan Vogel <sv@exept.de>
parents: 6156
diff changeset
    19
		ConversionErrorSignal'
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:]
6691
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    50
        ArithmeticSignal        <Error>         parent of all arithmetic signals
1283
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
    51
                                                (never raised itself)
5957
bfe534c912f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5955
diff changeset
    52
                                                New: now a reference to ArithmeticError
82
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    53
6691
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    54
        DomainErrorSignal       <Error>         raised upon float errors
1283
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
    55
                                                (for example range in trigonometric)
5957
bfe534c912f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5955
diff changeset
    56
                                                New: now a reference to DomainError
1283
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
    57
6691
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    58
        DivisionByZeroSignal    <Error>         raised when division by 0 is attempted
5957
bfe534c912f6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5955
diff changeset
    59
                                                New: now a reference to ZeroDivide
155
edd7fc34e104 *** empty log message ***
claus
parents: 92
diff changeset
    60
6691
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    61
        OverflowSignal          <Error>         raised on overflow/underflow conditions
1283
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
    62
        UnderflowSignal                         in float arithmetic. 
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
    63
                                                Notice: some OperatingSystems do not 
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
    64
                                                provide enough information for ST/X to 
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
    65
                                                extract the real reason for the floatException
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
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:]
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
    69
        Claus Gittinger
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:]
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
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:'initialization'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    77
5954
d706efecb134 ZeroDivide has a parameter
Claus Gittinger <cg@exept.de>
parents: 5948
diff changeset
    78
initialize
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    79
    "setup the signals"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    80
6691
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    81
    "/ notice that we now use class based exceptions;
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    82
    "/ however, for backward compatibility, the class variables
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    83
    "/ referring to those are kept for a while, for subclass compatibility.
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    84
    "/ Please convert your code to access those via the Signal-constants class
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    85
    "/ messages (accesors) instead of referring to the class variables.
5948
1fc30f692713 new class based exceptions
Claus Gittinger <cg@exept.de>
parents: 5238
diff changeset
    86
6691
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    87
    ArithmeticSignal := ArithmeticError.
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    88
    DomainErrorSignal := DomainError.
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    89
    DivisionByZeroSignal := ZeroDivide.
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    90
    UnorderedSignal := UnorderedNumbersError.
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    91
    ConversionErrorSignal := ConversionError.
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    92
    OverflowSignal := OverflowError.
48ba39288455 error notifiers are now initialized there
Claus Gittinger <cg@exept.de>
parents: 6342
diff changeset
    93
    UnderflowSignal := UnderflowError.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    94
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
    95
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    96
!ArithmeticValue class methodsFor:'Signal constants'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    97
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    98
arithmeticSignal
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    99
    "return the parent of all arithmetic signals"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   100
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   101
    ^ ArithmeticError
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   102
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   103
4995
9556c41783f5 added a conversionErrorSignal
Claus Gittinger <cg@exept.de>
parents: 4453
diff changeset
   104
conversionErrorSignal
9556c41783f5 added a conversionErrorSignal
Claus Gittinger <cg@exept.de>
parents: 4453
diff changeset
   105
    "return the signal which is raised when a conversion fails
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   106
     (such as when a NaN is to be converted)"
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   107
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   108
    ^ ConversionError
4995
9556c41783f5 added a conversionErrorSignal
Claus Gittinger <cg@exept.de>
parents: 4453
diff changeset
   109
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   110
    "
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   111
     ConversionError handle:[:ex |
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   112
        Transcript flash
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
     do:[
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   115
        (0.0 uncheckedDivide:0.0) asFraction
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   116
     ]
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   117
    "
4995
9556c41783f5 added a conversionErrorSignal
Claus Gittinger <cg@exept.de>
parents: 4453
diff changeset
   118
!
9556c41783f5 added a conversionErrorSignal
Claus Gittinger <cg@exept.de>
parents: 4453
diff changeset
   119
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   120
divisionByZeroSignal
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   121
    "return the signal which is raised on division by zero"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   122
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   123
    ^ ZeroDivide
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   124
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   125
a27a279701f8 Initial revision
claus
parents:
diff changeset
   126
domainErrorSignal
a27a279701f8 Initial revision
claus
parents:
diff changeset
   127
    "return the signal which is raised on math errors
a27a279701f8 Initial revision
claus
parents:
diff changeset
   128
     (such as log of 0 etc.)"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   129
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   130
    ^ DomainError
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   131
!
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   132
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   133
imaginaryResultSignal
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   134
    "return the signal which is raised when an imaginary result would be created
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   135
     (such as when taking the sqrt of a negative number)"
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   136
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   137
    ^ ImaginaryResultError
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   138
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   139
a27a279701f8 Initial revision
claus
parents:
diff changeset
   140
overflowSignal
a27a279701f8 Initial revision
claus
parents:
diff changeset
   141
    "return the signal which is raised on overflow conditions (in floats)"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   142
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   143
    ^ OverflowError
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   144
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   145
5955
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   146
rangeErrorSignal
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   147
    "return the parent of the overflow/underflow signals"
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   148
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   149
    ^ RangeError
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   150
!
4d973d840a00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   151
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   152
underflowSignal
a27a279701f8 Initial revision
claus
parents:
diff changeset
   153
    "return the signal which is raised on underflow conditions (in floats)"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   154
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   155
    ^ UnderflowError
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   156
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   157
345
claus
parents: 326
diff changeset
   158
unorderedSignal
claus
parents: 326
diff changeset
   159
    "return the signal which is raised when numbers are compared, 
claus
parents: 326
diff changeset
   160
     for which no ordering is defined (for example: complex numbers)"
claus
parents: 326
diff changeset
   161
7403
857702a5a921 signals vs. errors
Claus Gittinger <cg@exept.de>
parents: 7399
diff changeset
   162
    ^ UnorderedNumbersError
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   163
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   164
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   165
!ArithmeticValue methodsFor:'arithmetic'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   166
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   167
* something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   168
    "return the product of the receiver and the argument"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   169
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   170
    ^ self subclassResponsibility
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   171
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   172
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   173
+ something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   174
    "return the sum of the receiver and the argument"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   175
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   176
    ^ self subclassResponsibility
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   177
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   178
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   179
- something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   180
    "return the difference of the receiver and the argument"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   181
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   182
    ^ self subclassResponsibility
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   183
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   184
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   185
/ something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   186
    "return the quotient of the receiver and the argument"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   187
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   188
    ^ self subclassResponsibility
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   189
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   190
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   191
// something
1881
0c6ba2c134c1 fixed #rounded
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   192
    "return the integer quotient of dividing the receiver by aNumber with
0c6ba2c134c1 fixed #rounded
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   193
     truncation towards negative infinity."
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   194
3982
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   195
    "/ Note: '^ (self / something) floor' may lead to infinite recursion
1172
b135d4ae4bf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   196
b135d4ae4bf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   197
    ^ self subclassResponsibility
b135d4ae4bf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   198
3982
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   199
    "Modified: / 5.11.1996 / 11:46:27 / cg"
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   200
    "Modified: / 12.2.1998 / 16:31:36 / stefan"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   201
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   202
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   203
\\ something
3982
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   204
    "return the receiver modulo something.
6067
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   205
     The remainder has the same sign as something.
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   206
     The following is always true:
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   207
        (receiver // something) * something + (receiver \\ something) = receiver
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   208
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   209
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   210
    ^ self - ((self // something) * something)
3134
22c7071ff004 Fix typo.
Stefan Vogel <sv@exept.de>
parents: 1888
diff changeset
   211
3982
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   212
   "
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   213
     0.9 \\ 0.4
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   214
     0.9 \\ -0.4
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   215
    -0.9 \\ 0.4
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   216
    -0.9 \\ -0.4
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   217
   "
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   218
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   219
    "Modified: / 12.2.1998 / 19:14:37 / stefan"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   220
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   221
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   222
abs
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   223
    "return the absolute value of the receiver"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   224
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   225
    (self negative) ifTrue:[^ self negated].
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   226
    ^ self
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   227
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   228
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   229
negated
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   230
    "return the receiver negated"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   231
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   232
    ^ self class zero - self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   233
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   234
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   235
quo:something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   236
    "Return the integer quotient of dividing the receiver by the argument
6067
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   237
     with truncation towards zero.
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   238
     The following is always true:
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   239
        (receiver quo: aNumber) * aNumber + (receiver rem: aNumber) = receiver
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   240
    "
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   241
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   242
    ^ (self / something) truncated
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   243
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   244
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   245
reciprocal
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   246
    "return the receivers reciprocal"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   247
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   248
    ^ self class unity / self
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   249
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   250
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   251
rem:something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   252
    "Return the integer remainder of dividing the receiver by the argument
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   253
     with truncation towards zero.
6067
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   254
     The remainder has the same sign as the receiver.
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   255
     The following is always true:
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   256
        (receiver quo: something) * something + (receiver rem: something) = receiver
e4c03d14a5de comment
Claus Gittinger <cg@exept.de>
parents: 5987
diff changeset
   257
    "
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   258
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   259
    ^ self - ((self quo:something) * something)
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   260
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   261
5238
f7a816a660a3 categories
Claus Gittinger <cg@exept.de>
parents: 4995
diff changeset
   262
!ArithmeticValue methodsFor:'coercing & converting'!
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   263
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   264
coerce:aNumber
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   265
    "convert aNumber into an instance of the receivers class and return it."
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   266
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   267
    ^ self subclassResponsibility
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   268
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   269
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   270
generality
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   271
    "return a number giving the receivers generality, that number is
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   272
     used to convert one of the arguments in a mixed expression. 
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   273
     The generality has to be defined in subclasses,
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   274
     such that gen(a) > gen(b) iff, conversion of b into a's class 
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   275
     does not cut precision. For example, Integer has 40, Float has 80,
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   276
     meaning that if we convert a Float to an Integer, some precision may
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   277
     be lost. The generality is used by ArithmeticValue>>retry:coercing:,
3982
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   278
     which converts the lower-precision number to the higher precision
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   279
     numbers class, when mixed-type arithmetic is performed."
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   280
      
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   281
    ^ self subclassResponsibility
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   282
3982
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   283
    "Modified: / 5.11.1996 / 15:05:30 / cg"
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   284
    "Modified: / 13.2.1998 / 15:36:01 / stefan"
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   285
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   286
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   287
retry:aSymbol coercing:aNumber
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   288
    "arithmetic represented by the binary operator, aSymbol,
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   289
     could not be performed with the receiver and the argument, aNumber, 
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   290
     because of the differences in representation.  
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   291
     Coerce either the receiver or the argument, depending on which has higher 
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   292
     generality, and try again.  
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   293
     If the operation is compare for same value (=), return false if
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   294
     the argument is not a Number. 
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   295
     If the generalities are the same, create an error message, since this
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   296
     means that a subclass has not been fully implemented."
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   297
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   298
    |hasGenerality myGenerality otherGenerality|
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   299
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   300
    hasGenerality := aNumber respondsTo:#generality.
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   301
    hasGenerality ifFalse:[
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   302
        (aSymbol == #=) ifTrue:[
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   303
            ^ false
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   304
        ].
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   305
        (aSymbol == #~=) ifTrue:[
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   306
            ^ true
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   307
        ].
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   308
        ^ self error:'retry:coercing: argument is not a number'.
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   309
    ].
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   310
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   311
    myGenerality := self generality.
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   312
    otherGenerality := aNumber generality.
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   313
    (myGenerality > otherGenerality) ifTrue:[
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   314
        ^ self perform:aSymbol with:(self coerce:aNumber)
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   315
    ].
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   316
    (myGenerality < otherGenerality) ifTrue:[
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   317
        ^ (aNumber coerce:self) perform:aSymbol with:aNumber
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   318
    ].
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   319
    self error:'retry:coercing: oops - same generality'
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   320
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   321
    "Modified: 5.11.1996 / 15:03:38 / cg"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   322
! !
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   323
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   324
!ArithmeticValue methodsFor:'comparing'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   325
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   326
< something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   327
    "return true, if the argument is greater than the receiver"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   328
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   329
    ^ self subclassResponsibility
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   330
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   331
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   332
<= something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   333
    "return true, if the argument is greater or equal than the receiver"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   334
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   335
    ^ (something < self) not
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   336
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   337
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   338
> something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   339
    "return true, if the argument is less than the receiver"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   340
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   341
    ^ something < self
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   342
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   343
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   344
>= something
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   345
    "return true, if the argument is less or equal than the receiver"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   346
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   347
    ^ (self < something) not
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   348
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   349
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   350
compare:arg ifLess:lessBlock ifEqual:equalBlock ifGreater:greaterBlock
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   351
    "three-way compare - thanks to Self for this idea.
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   352
     Can be redefined in subclasses to do it with a single comparison if
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   353
     comparison is expensive."
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   354
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   355
    self < arg ifTrue:[
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   356
	^ lessBlock value
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   357
    ].
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   358
    self = arg ifTrue:[
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   359
	^ equalBlock value
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   360
    ].
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   361
    ^ greaterBlock value
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   362
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   363
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   364
!ArithmeticValue methodsFor:'converting'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   365
3982
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   366
asDouble
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   367
    "ST80 compatibility: return our floats are the identical to ST80 doubles"
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   368
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   369
   ^ self asFloat
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   370
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   371
    "Created: / 13.2.1998 / 15:40:14 / stefan"
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   372
!
22fdd79b2d9d Define asDouble for ST80 compatibility.
Stefan Vogel <sv@exept.de>
parents: 3654
diff changeset
   373
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   374
asFloat
a27a279701f8 Initial revision
claus
parents:
diff changeset
   375
    "return a float with same value"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   376
a27a279701f8 Initial revision
claus
parents:
diff changeset
   377
   ^ self subclassResponsibility
a27a279701f8 Initial revision
claus
parents:
diff changeset
   378
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   379
5986
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   380
asFloatD
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   381
    "return a double precision float with same value.
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   382
     Added for ANSI compatibility"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   383
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   384
   ^ self asFloat
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   385
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   386
    "Created: / 7.9.2001 / 13:36:48 / cg"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   387
    "Modified: / 7.9.2001 / 13:38:10 / cg"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   388
!
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   389
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   390
asFloatE
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   391
    "return a single precision float with same value.
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   392
     Added for ANSI compatibility"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   393
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   394
   ^ self asShortFloat
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   395
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   396
    "Created: / 7.9.2001 / 13:37:06 / cg"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   397
    "Modified: / 7.9.2001 / 13:38:15 / cg"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   398
!
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   399
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   400
asFloatQ
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   401
    "return a quad precision float with same value.
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   402
     Added for ANSI compatibility"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   403
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   404
   ^ self asLongFloat
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   405
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   406
    "Created: / 7.9.2001 / 13:38:44 / cg"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   407
!
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   408
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   409
asFraction
a27a279701f8 Initial revision
claus
parents:
diff changeset
   410
    "return a fraction with same value"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   411
a27a279701f8 Initial revision
claus
parents:
diff changeset
   412
   ^ self subclassResponsibility
a27a279701f8 Initial revision
claus
parents:
diff changeset
   413
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   414
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   415
asInteger
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   416
    "return an integer with same value - might truncate"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   417
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   418
    ^ self truncated
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   419
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   420
7378
e71a28f6b712 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7355
diff changeset
   421
asLimitedPrecisionReal
e71a28f6b712 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7355
diff changeset
   422
    "return a float of any precision with same value"
e71a28f6b712 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7355
diff changeset
   423
e71a28f6b712 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7355
diff changeset
   424
   ^ self asFloat
e71a28f6b712 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7355
diff changeset
   425
!
e71a28f6b712 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7355
diff changeset
   426
5986
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   427
asLongFloat
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   428
    "return a longFloat with same value"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   429
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   430
   "WARNING: could loose precision here, if not redefined in concrete classes which
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   431
    have more than float precision (i.e. LargeIntegers and Fractions)"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   432
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   433
   ^ self asFloat asLongFloat "/ subclassResponsibility
5986
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   434
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   435
    "Modified: / 17.4.1996 / 12:21:35 / cg"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   436
    "Created: / 7.9.2001 / 13:39:31 / cg"
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   437
!
3d8c2676e913 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5957
diff changeset
   438
5987
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
   439
asScaledDecimal:scale
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
   440
    "return a fixedPoint approximating the receivers value"
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
   441
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
   442
    ^ self asFixedPoint:scale
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
   443
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
   444
    "
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
   445
     1.234 asScaledDecimal:2
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
   446
    "
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
   447
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
   448
    "Created: / 7.9.2001 / 13:46:26 / cg"
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
   449
    "Modified: / 7.9.2001 / 13:46:44 / cg"
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
   450
!
Claus Gittinger <cg@exept.de>
parents: 5986
diff changeset
   451
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   452
asShortFloat
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   453
    "return a shortFloat with same value"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   454
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   455
   ^ self asFloat asShortFloat
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   456
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   457
    "Modified: 17.4.1996 / 12:21:35 / cg"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   458
!
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   459
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   460
degreesToRadians
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   461
    "interpreting the receiver as radians, return the degrees"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   462
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   463
    ^ self asFloat degreesToRadians
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   464
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   465
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   466
radiansToDegrees
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   467
    "interpreting the receiver as degrees, return the radians"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   468
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   469
    ^ self asFloat radiansToDegrees
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   470
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   471
4138
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   472
!ArithmeticValue methodsFor:'destructive arithmethic'!
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   473
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   474
*= aNumber
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   475
    "Return the product of self multiplied by aNumber. 
7228
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   476
     The receiver MAY, but NEED NOT be changed to contain the product.
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   477
     So this method must be used as: 'a := a *= 5'.
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   478
     This method can be redefined for constructed datatypes to do optimisations"
4138
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   479
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   480
    ^ self * aNumber
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   481
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   482
    "Created: / 28.4.1999 / 11:46:11 / stefan"
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   483
    "Modified: / 28.4.1999 / 11:53:28 / stefan"
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   484
!
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   485
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   486
+= aNumber
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   487
    "Return the sum of self and aNumber. 
7228
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   488
     The receiver MAY, but NEED NOT be changed to contain the sum.
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   489
     So this method must be used as: 'a := a += 5'.
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   490
     This method can be redefined for constructed datatypes to do optimisations"
4138
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   491
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   492
    ^ self + aNumber
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   493
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   494
    "Created: / 28.4.1999 / 10:13:41 / stefan"
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   495
    "Modified: / 28.4.1999 / 11:54:11 / stefan"
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   496
!
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   497
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   498
-= aNumber
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   499
    "Return the difference of self and aNumber. 
7228
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   500
     The receiver MAY, but NEED NOT be changed to contain the difference.
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   501
     So this method must be used as: 'a := a -= 5'.
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   502
     This method can be redefined for constructed datatypes to do optimisations"
4138
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   503
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   504
    ^ self - aNumber
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   505
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   506
    "Created: / 28.4.1999 / 10:13:58 / stefan"
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   507
    "Modified: / 28.4.1999 / 11:54:37 / stefan"
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   508
!
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   509
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   510
/= aNumber
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   511
    "Return the quotient of self and aNumber. 
7228
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   512
     The receiver MAY, but NEED NOT be changed to contain the quotient.
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   513
     So this method must be used as: 'a := a /= 5'.
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   514
     This method can be redefined for constructed datatypes to do optimisations"
4138
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   515
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   516
    ^ self / aNumber
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   517
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   518
    "Created: / 28.4.1999 / 11:46:22 / stefan"
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   519
    "Modified: / 28.4.1999 / 11:55:06 / stefan"
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   520
!
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   521
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   522
div2
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   523
    "Return the quotient of self divided by 2. 
7228
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   524
     The receiver MAY, but NEED NOT be changed to contain the result.
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   525
     So this method must be used as: 'a := a div2.
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   526
     This method can be redefined for constructed datatypes to do optimisations"
4138
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   527
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   528
    ^ self // 2
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   529
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   530
    "Created: / 28.4.1999 / 10:12:44 / stefan"
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   531
    "Modified: / 28.4.1999 / 11:56:09 / stefan"
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   532
!
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   533
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   534
mul2
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   535
    "Return the product of self multiplied by 2. 
7228
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   536
     The receiver MAY, but NEED NOT be changed to contain the result.
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   537
     So this method must be used as: 'a := a mul2.
b7c66af018f8 comments
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   538
     This method can be redefined for constructed datatypes to do optimisations"
4138
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   539
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   540
    ^ self * 2
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   541
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   542
    "Created: / 28.4.1999 / 10:12:55 / stefan"
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   543
    "Modified: / 28.4.1999 / 11:56:38 / stefan"
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   544
! !
c5030c520941 New methods for destructive arithmethics like +=, -= ...
Stefan Vogel <sv@exept.de>
parents: 3982
diff changeset
   545
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   546
!ArithmeticValue methodsFor:'double dispatching'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   547
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   548
differenceFromComplex:aComplex
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   549
    "the receiver does not know how to subtract from a complex -
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   550
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   551
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   552
    ^ aComplex retry:#- coercing:self
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   553
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   554
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   555
differenceFromFixedPoint:aFixedPoint
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   556
    "the receiver does not know how to subtract from a fixedPoint number -
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   557
     retry the operation by coercing to higher generality"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   558
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   559
    ^ aFixedPoint retry:#- coercing:self
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   560
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   561
    "Created: 5.11.1996 / 14:55:51 / cg"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   562
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   563
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   564
differenceFromFloat:aFloat
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   565
    "the receiver does not know how to subtract from a float -
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   566
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   567
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   568
    ^ aFloat retry:#- coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   569
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   570
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   571
differenceFromFraction:aFraction
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   572
    "the receiver does not know how to subtract from a fraction -
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   573
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   574
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   575
    ^ aFraction retry:#- coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   576
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   577
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   578
differenceFromInteger:anInteger
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   579
    "the receiver does not know how to subtract from an integer -
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   580
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   581
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   582
    ^ anInteger retry:#- coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   583
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   584
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   585
differenceFromLongFloat:aLongFloat
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   586
    "the receiver does not know how to subtract from a longFloat -
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   587
     retry the operation by coercing to higher generality"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   588
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   589
    ^ aLongFloat retry:#- coercing:self
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   590
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   591
    "Created: 17.4.1996 / 12:33:16 / cg"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   592
!
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   593
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   594
differenceFromShortFloat:aShortFloat
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   595
    "the receiver does not know how to subtract from a shortFloat -
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   596
     retry the operation by coercing to higher generality"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   597
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   598
    ^ aShortFloat retry:#- coercing:self
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   599
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   600
    "Created: 17.4.1996 / 12:33:16 / cg"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   601
!
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   602
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   603
equalFromComplex:aComplex
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   604
    "the receiver does not know how to compare to a complex number -
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   605
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   606
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   607
    ^ aComplex retry:#= coercing:self
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   608
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   609
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   610
equalFromFixedPoint:aFixedPoint
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   611
    "the receiver does not know how to compare to a fixed point -
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   612
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   613
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   614
    ^ aFixedPoint retry:#= coercing:self
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   615
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   616
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   617
equalFromFloat:aFloat
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   618
    "the receiver does not know how to compare to a float -
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   619
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   620
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   621
    ^ aFloat retry:#= coercing:self
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   622
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   623
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   624
equalFromFraction:aFraction
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   625
    "the receiver does not know how to compare to a fraction -
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   626
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   627
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   628
    ^ aFraction retry:#= coercing:self
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   629
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   630
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   631
equalFromInteger:anInteger
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   632
    "the receiver does not know how to compare to an integer -
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   633
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   634
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   635
    ^ anInteger retry:#= coercing:self
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   636
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   637
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   638
equalFromLongFloat:aLongFloat
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   639
    "the receiver does not know how to compare to a long float -
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   640
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   641
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   642
    ^ aLongFloat retry:#= coercing:self
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   643
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   644
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   645
equalFromShortFloat:aShortFloat
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   646
    "the receiver does not know how to compare to a short float -
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   647
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   648
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   649
    ^ aShortFloat retry:#= coercing:self
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   650
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   651
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   652
lessFromFixedPoint:aFixedPoint
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   653
    "the receiver does not know how to compare to a fixedPoint number -
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   654
     retry the operation by coercing to higher generality"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   655
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   656
    ^ aFixedPoint retry:#< coercing:self
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   657
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   658
    "Created: 5.11.1996 / 14:56:12 / cg"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   659
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   660
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   661
lessFromFloat:aFloat
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   662
    "the receiver does not know how to compare to a float -
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   663
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   664
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   665
    ^ aFloat retry:#< coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   666
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   667
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   668
lessFromFraction:aFraction
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   669
    "the receiver does not know how to compare to a fraction -
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   670
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   671
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   672
    ^ aFraction retry:#< coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   673
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   674
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   675
lessFromInteger:anInteger
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   676
    "the receiver does not know how to compare to an integer -
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   677
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   678
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   679
    ^ anInteger retry:#< coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   680
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   681
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   682
lessFromLongFloat:aLongFloat
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   683
    "the receiver does not know how to compare to a longFloat -
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   684
     retry the operation by coercing to higher generality"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   685
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   686
    ^ aLongFloat retry:#< coercing:self
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   687
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   688
    "Modified: 17.4.1996 / 12:33:33 / cg"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   689
!
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   690
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   691
lessFromShortFloat:aShortFloat
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   692
    "the receiver does not know how to compare to a shortFloat -
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   693
     retry the operation by coercing to higher generality"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   694
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   695
    ^ aShortFloat retry:#< coercing:self
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   696
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   697
    "Modified: 17.4.1996 / 12:33:33 / cg"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   698
!
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   699
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   700
productFromComplex:aComplex
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   701
    "the receiver does not know how to multiply a complex -
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   702
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   703
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   704
    ^ aComplex retry:#* coercing:self
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   705
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   706
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   707
productFromFixedPoint:aFixedPoint
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   708
    "the receiver does not know how to multiply a fixed point number -
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   709
     retry the operation by coercing to higher generality"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   710
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   711
    ^ aFixedPoint retry:#* coercing:self
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   712
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   713
    "Created: 5.11.1996 / 14:56:28 / cg"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   714
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   715
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   716
productFromFloat:aFloat
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   717
    "the receiver does not know how to multiply a float -
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   718
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   719
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   720
    ^ aFloat retry:#* coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   721
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   722
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   723
productFromFraction:aFraction
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   724
    "the receiver does not know how to multiply a fraction -
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   725
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   726
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   727
    ^ aFraction retry:#* coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   728
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   729
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   730
productFromInteger:anInteger
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   731
    "the receiver does not know how to multiply an integer -
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   732
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   733
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   734
    ^ anInteger retry:#* coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   735
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   736
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   737
productFromLongFloat:aLongFloat
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   738
    "the receiver does not know how to multiply a longFloat -
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   739
     retry the operation by coercing to higher generality"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   740
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   741
    ^ aLongFloat retry:#* coercing:self
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   742
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   743
    "Created: 17.4.1996 / 12:33:48 / cg"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   744
!
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   745
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   746
productFromShortFloat:aShortFloat
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   747
    "the receiver does not know how to multiply a shortFloat -
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   748
     retry the operation by coercing to higher generality"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   749
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   750
    ^ aShortFloat retry:#* coercing:self
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   751
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   752
    "Created: 17.4.1996 / 12:33:48 / cg"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   753
!
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   754
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   755
quotientFromComplex:aComplex
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   756
    "the receiver does not know how to divide a complex -
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   757
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   758
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   759
    ^ aComplex retry:#/ coercing:self
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   760
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   761
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   762
quotientFromFixedPoint:aFixedPoint
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   763
    "the receiver does not know how to divide a fixed point number -
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   764
     retry the operation by coercing to higher generality"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   765
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   766
    ^ aFixedPoint retry:#/ coercing:self
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   767
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   768
    "Created: 5.11.1996 / 14:56:41 / cg"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   769
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   770
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   771
quotientFromFloat:aFloat
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   772
    "the receiver does not know how to divide a float -
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   773
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   774
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   775
    ^ aFloat retry:#/ coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   776
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   777
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   778
quotientFromFraction:aFraction
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   779
    "the receiver does not know how to divide a fraction -
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   780
     retry the operation by coercing to higher generality"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   781
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   782
    ^ aFraction retry:#/ coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   783
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   784
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   785
quotientFromInteger:anInteger
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   786
    "the receiver does not know how to divide an integer -
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   787
     retry the operation by coercing to higher generality"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   788
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   789
    ^ anInteger retry:#/ coercing:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   790
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   791
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   792
quotientFromLongFloat:aLongFloat
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   793
    "the receiver does not know how to divide a longFloat -
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   794
     retry the operation by coercing to higher generality"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   795
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   796
    ^ aLongFloat retry:#/ coercing:self
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   797
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   798
    "Created: 17.4.1996 / 12:34:00 / cg"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   799
!
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   800
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   801
quotientFromShortFloat:aShortFloat
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   802
    "the receiver does not know how to divide a shortFloat -
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   803
     retry the operation by coercing to higher generality"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   804
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   805
    ^ aShortFloat retry:#/ coercing:self
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   806
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   807
    "Created: 17.4.1996 / 12:34:00 / cg"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   808
!
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   809
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   810
sumFromComplex:aComplex
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   811
    "the receiver does not know how to add a complex -
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   812
     retry the operation by coercing to higher generality"
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   813
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   814
    ^ aComplex retry:#+ coercing:self
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   815
!
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
   816
1888
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   817
sumFromFixedPoint:aFixedPoint
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   818
    "the receiver does not know how to add a fixed point number -
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   819
     retry the operation by coercing to higher generality"
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
    ^ aFixedPoint retry:#+ coercing:self
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
    "Created: 5.11.1996 / 14:56:56 / cg"
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   824
!
463d49ca22e3 fixedPoint support
Claus Gittinger <cg@exept.de>
parents: 1881
diff changeset
   825
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   826
sumFromFloat:aFloat
a27a279701f8 Initial revision
claus
parents:
diff changeset
   827
    "the receiver does not know how to add a float -
a27a279701f8 Initial revision
claus
parents:
diff changeset
   828
     retry the operation by coercing to higher generality"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   829
a27a279701f8 Initial revision
claus
parents:
diff changeset
   830
    ^ aFloat retry:#+ coercing:self
a27a279701f8 Initial revision
claus
parents:
diff changeset
   831
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   832
a27a279701f8 Initial revision
claus
parents:
diff changeset
   833
sumFromFraction:aFraction
a27a279701f8 Initial revision
claus
parents:
diff changeset
   834
    "the receiver does not know how to add a fraction -
a27a279701f8 Initial revision
claus
parents:
diff changeset
   835
     retry the operation by coercing to higher generality"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   836
a27a279701f8 Initial revision
claus
parents:
diff changeset
   837
    ^ aFraction retry:#+ coercing:self
a27a279701f8 Initial revision
claus
parents:
diff changeset
   838
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   839
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   840
sumFromInteger:anInteger
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   841
    "the receiver does not know how to add an integer -
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   842
     retry the operation by coercing to higher generality"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   843
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   844
    ^ anInteger retry:#+ coercing:self
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   845
!
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   846
7399
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   847
sumFromLongFloat:aLongFloat
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   848
    "the receiver does not know how to add a longFloat -
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   849
     retry the operation by coercing to higher generality"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   850
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   851
    ^ aLongFloat retry:#+ coercing:self
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   852
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   853
    "Created: 17.4.1996 / 12:34:10 / cg"
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   854
!
43d62fad41b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
   855
1200
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   856
sumFromShortFloat:aShortFloat
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   857
    "the receiver does not know how to add a shortFloat -
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   858
     retry the operation by coercing to higher generality"
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   859
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   860
    ^ aShortFloat retry:#+ coercing:self
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   861
cc16f7a00b52 limited shortFloat support
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   862
    "Created: 17.4.1996 / 12:34:10 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   863
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   864
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
   865
!ArithmeticValue methodsFor:'mathematical functions'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   866
6858
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   867
** aNumber
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   868
    "return the receiver raised to aNumber"
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   869
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   870
    ^ self raisedTo:aNumber
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   871
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   872
    "
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   873
     2 ** 4    
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   874
     10 ** 4    
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   875
    "
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   876
!
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   877
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   878
exp
a27a279701f8 Initial revision
claus
parents:
diff changeset
   879
    "return e ^ receiver"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   880
7391
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
   881
    ^ self class e raisedTo:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   882
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   883
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   884
floorLog:radix
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   885
    "return the logarithm truncated as an integer"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   886
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   887
    ^ (self log:radix) floor
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   888
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   889
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   890
ln
a27a279701f8 Initial revision
claus
parents:
diff changeset
   891
    "return the natural logarithm of the receiver"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   892
a27a279701f8 Initial revision
claus
parents:
diff changeset
   893
    ^ self asFloat ln
a27a279701f8 Initial revision
claus
parents:
diff changeset
   894
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   895
a27a279701f8 Initial revision
claus
parents:
diff changeset
   896
log
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
   897
    "return log base 10 of the receiver.
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
   898
     Alias for log10."
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
   899
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
   900
    ^ self log10
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
   901
!
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
   902
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
   903
log10
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   904
    "return log base 10 of the receiver"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   905
a27a279701f8 Initial revision
claus
parents:
diff changeset
   906
    ^ self log:10
a27a279701f8 Initial revision
claus
parents:
diff changeset
   907
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   908
a27a279701f8 Initial revision
claus
parents:
diff changeset
   909
log:aNumber
a27a279701f8 Initial revision
claus
parents:
diff changeset
   910
    "return log base aNumber of the receiver"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   911
a27a279701f8 Initial revision
claus
parents:
diff changeset
   912
    ^ self ln / aNumber ln
a27a279701f8 Initial revision
claus
parents:
diff changeset
   913
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   914
a27a279701f8 Initial revision
claus
parents:
diff changeset
   915
raisedTo:aNumber
a27a279701f8 Initial revision
claus
parents:
diff changeset
   916
    "return the receiver raised to aNumber"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   917
a27a279701f8 Initial revision
claus
parents:
diff changeset
   918
    aNumber = 0 ifTrue:[^ 1].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   919
    aNumber = 1 ifTrue:[^ self].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   920
    aNumber isInteger ifTrue:[
6858
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   921
        ^ self raisedToInteger:aNumber
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   922
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   923
    ^ self asFloat raisedTo:aNumber
6858
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   924
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   925
    "
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   926
     2 raisedTo: 4    
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   927
     10 raisedTo: 4    
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   928
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   929
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   930
6858
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   931
raisedToInteger:exp 
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   932
    "return the receiver raised to exp"
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   933
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7384
diff changeset
   934
    |result e t|
6858
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   935
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7384
diff changeset
   936
    "use the addition chaining algorithm,
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7384
diff changeset
   937
     which is much faster for big exp-arguments"
6858
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   938
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   939
    result := 1.
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   940
    t := self.
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   941
    exp < 0 ifTrue:[
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   942
        e := exp negated.
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   943
    ] ifFalse:[
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   944
        e := exp.
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   945
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   946
6858
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   947
    [e ~~ 0] whileTrue:[
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   948
        [(e bitAnd:1) == 0] whileTrue:[
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   949
            e := e bitShift:-1.
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   950
            t := t * t.
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   951
        ].
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   952
        e := e - 1.
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   953
        result := result * t.
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   954
    ].
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   955
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   956
    (exp < 0) ifTrue:[
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   957
        ^ 1 / result
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   958
    ].
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   959
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   960
    ^ result
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   961
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   962
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   963
    "
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   964
     (2 raisedToInteger:216)
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   965
     (2 raisedTo:216) 
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   966
-> 105312291668557186697918027683670432318895095400549111254310977536     
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   967
6858
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   968
     (2 raisedToInteger:216) asFloat     
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   969
     (2 raisedTo:216) asFloat     
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   970
-> 1.05312E+65
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   971
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   972
     (2 raisedToInteger:500)
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   973
     (2 raisedTo:500) 
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   974
-> 3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   975
     2 raisedToInteger:10 
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   976
-> 1024
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   977
    -2 raisedToInteger:10
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   978
-> 1024
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   979
     -2 raisedToInteger:9
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   980
-> -512
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   981
     10 raisedToInteger:-10
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   982
-> (1/10000000000)
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   983
     2 raisedToInteger:0 
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   984
-> 1
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   985
     2 raisedToInteger:-1 
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   986
-> (1/2)
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   987
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   988
     Time millisecondsToRun:[
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   989
        10000 timesRepeat:[
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   990
            (2 raisedToInteger:500)
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   991
        ]
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   992
     ]  
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   993
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   994
     Time millisecondsToRun:[
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   995
        |bigNum|
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   996
        bigNum := 2 raisedToInteger:500.
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   997
        10 timesRepeat:[
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   998
            (bigNum raisedToInteger:500)
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   999
        ]
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1000
     ]
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1001
    "
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1002
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1003
    "Created: / 27.4.1999 / 15:19:22 / stefan"
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1004
    "Modified: / 27.4.1999 / 16:16:11 / stefan"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1005
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1006
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1007
sqrt
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1008
    "return the square root of the receiver"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1009
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1010
    ^ self asFloat sqrt
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1011
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1012
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1013
squared
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1014
    "return receiver * receiver"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1015
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1016
    ^ self * self
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1017
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1018
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1019
!ArithmeticValue methodsFor:'queries'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1020
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1021
respondsToArithmetic
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1022
    "return true, if the receiver responds to arithmetic messages"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1023
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1024
    ^ true
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1025
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1026
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1027
!ArithmeticValue methodsFor:'testing'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1028
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1029
denominator
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1030
    "return the denominator of the receiver"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1031
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1032
    ^ 1
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1033
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1034
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1035
even
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1036
    "return true if the receiver is divisible by 2"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1037
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1038
    ^ self truncated asInteger even
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1039
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1040
3635
3fcccef48db3 complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3393
diff changeset
  1041
isComplex
7355
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1042
    "Answer whether the receiver has an imaginary part
96f466eeddf5 double dispatching fixed;
Claus Gittinger <cg@exept.de>
parents: 7228
diff changeset
  1043
     (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
  1044
3fcccef48db3 complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3393
diff changeset
  1045
    ^ false
3fcccef48db3 complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3393
diff changeset
  1046
3fcccef48db3 complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3393
diff changeset
  1047
    "Modified: / 9.7.1998 / 10:19:27 / cg"
3fcccef48db3 complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3393
diff changeset
  1048
!
3fcccef48db3 complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3393
diff changeset
  1049
6156
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  1050
isReal
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  1051
    "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
  1052
     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
  1053
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  1054
    ^ false
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  1055
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  1056
    "Modified: / 6.11.2001 / 13:20:20 / cg"
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  1057
    "Created: / 6.11.2001 / 13:26:29 / cg"
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  1058
!
ff2df95a69bf isReal moved
Claus Gittinger <cg@exept.de>
parents: 6067
diff changeset
  1059
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1060
negative
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1061
    "return true, if the receiver is < 0"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1062
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1063
    " this would lead to infinite recursion ...
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1064
    ^ (self < 0)
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1065
    "
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1066
    ^ self subclassResponsibility
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1067
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1068
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1069
numerator
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1070
    "return the numerator of the receiver."
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1071
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1072
    ^ self
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1073
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1074
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1075
odd
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1076
    "return true if the receiver is not divisible by 2"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1077
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1078
    ^ self even not
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1079
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1080
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1081
positive
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1082
    "return true, if the receiver is >= 0"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1083
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1084
    ^ self negative not
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1085
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1086
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1087
sign
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1088
    "return the sign of the receiver"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1089
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1090
    (self < 0) ifTrue:[^ -1].
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1091
    (self > 0) ifTrue:[^ 1].
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1092
    ^ 0
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1093
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1094
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1095
strictlyPositive
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1096
    "return true, if the receiver is > 0"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1097
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1098
    ^ (self > 0)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1099
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1100
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1101
!ArithmeticValue methodsFor:'trigonometric'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1102
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1103
arcCos
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1104
    "return the arccosine of the receiver (in radians)"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1105
7416
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1106
    self class == Float ifTrue:[
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1107
        ^ self subclassResponsibility.
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1108
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1109
    ^ self asFloat arcCos
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1110
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1111
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1112
arcCosh
7391
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1113
    "return the hyperbolic arccosine of the receiver."
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1114
7416
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1115
    self class == Float ifTrue:[
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1116
        ^ self subclassResponsibility.
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1117
    ].
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1118
    ^ self asFloat arcCosh
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1119
!
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1120
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1121
arcSin
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1122
    "return the arcsine of the receiver (in radians)"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1123
7416
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1124
    self class == Float ifTrue:[
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1125
        ^ self subclassResponsibility.
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1126
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1127
    ^ self asFloat arcSin
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1128
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1129
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1130
arcSinh
7391
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1131
    "return the hyperbolic arcsine of the receiver."
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1132
7416
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1133
    self class == Float ifTrue:[
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1134
        ^ self subclassResponsibility.
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1135
    ].
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1136
    ^ self asFloat arcSinh
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1137
!
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1138
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1139
arcTan
7391
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1140
    "return the arctangent of the receiver (as radians)"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1141
7416
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1142
    self class == Float ifTrue:[
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1143
        ^ self subclassResponsibility.
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1144
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1145
    ^ self asFloat arcTan
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1146
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1147
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1148
arcTanh
7391
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1149
    "return the hyperbolic arctangent of the receiver."
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1150
7416
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1151
    self class == Float ifTrue:[
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1152
        ^ self subclassResponsibility.
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1153
    ].
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1154
    ^ self asFloat arcTanh
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1155
!
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1156
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1157
cos
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1158
    "return the cosine of the receiver (interpreted as radians)"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1159
7416
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1160
    self class == Float ifTrue:[
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1161
        ^ self subclassResponsibility.
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1162
    ].
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1163
    ^ self asFloat cos
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1164
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1165
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1166
cosh
7391
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1167
    "return the hyperbolic cosine of the receiver"
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1168
7391
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1169
    ^ (self exp + (self negated exp)) / 2
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1170
!
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1171
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1172
sin
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1173
    "return the sine of the receiver (interpreted as radians)"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1174
7416
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1175
    self class == Float ifTrue:[
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1176
        ^ self subclassResponsibility.
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1177
    ].
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1178
    ^ self asFloat sin
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1179
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1180
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1181
sinh
7391
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1182
    "return the hyperbolic sine of the receiver"
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1183
7391
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1184
    ^ (self exp - (self negated exp)) / 2
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1185
!
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1186
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1187
tan
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1188
    "return the tangens of the receiver (interpreted as radians)"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1189
7412
daae29634e02 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7403
diff changeset
  1190
    ^ self sin / self cos
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1191
!
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1192
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1193
tanh
7391
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1194
    "return the hyperbolic tangens of the receiver"
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1195
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1196
    |exp nexp|
7384
ae6b11a3b4d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7378
diff changeset
  1197
7391
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1198
    "/ tanh is:
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1199
    "/      sinh(x)
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1200
    "/      -------
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1201
    "/      cosh(x)
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1202
    "/
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1203
    "/ which is:
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1204
    "/      (exp(x) - exp(-x)) / 2
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1205
    "/      ----------------------
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1206
    "/      (exp(x) + exp(-x)) / 2
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1207
    
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1208
    exp := self exp.
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1209
    nexp := self negated exp.
55ca5a24162a added more math functions (hyperbolic)
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1210
7393
23344038fa0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7391
diff changeset
  1211
    ^ (exp - nexp) / (exp + nexp)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1212
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1213
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1214
!ArithmeticValue methodsFor:'truncation & rounding'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1215
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1216
ceiling
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1217
    "return the integer nearest the receiver towards positive infinity."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1218
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1219
    |anInteger|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1220
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1221
    anInteger := self // 1.       "truncates towards negative infinity"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1222
    anInteger = self ifTrue:[^ anInteger].
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1223
    ^ anInteger + 1
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1224
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1225
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1226
floor
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1227
    "return the receiver truncated towards negative infinity"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1228
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1229
    ^ self // 1
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1230
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1231
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1232
roundTo:aNumber
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1233
    "return the receiver rounded to multiples of aNumber"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1234
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1235
    ^ (self / aNumber) rounded * aNumber
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1236
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1237
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1238
rounded
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1239
    "return the integer nearest the receiver"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1240
1881
0c6ba2c134c1 fixed #rounded
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
  1241
    self negative ifTrue:[
0c6ba2c134c1 fixed #rounded
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
  1242
        ^ (self - 0.5) ceiling
0c6ba2c134c1 fixed #rounded
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
  1243
    ].
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1244
    ^ (self + 0.5) floor
1881
0c6ba2c134c1 fixed #rounded
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
  1245
0c6ba2c134c1 fixed #rounded
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
  1246
    "Modified: 5.11.1996 / 11:31:59 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1247
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1248
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1249
truncateTo:aNumber
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1250
    "return the receiver truncated to multiples of aNumber"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1251
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1252
    ^ ((self / aNumber) floor * aNumber) asInteger
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1253
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1254
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1255
truncated
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1256
    "return the receiver truncated towards zero"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1257
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1258
    self negative ifTrue:[
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1259
	^ self ceiling
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1260
    ].
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1261
    ^ self floor
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1262
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1263
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1264
!ArithmeticValue class methodsFor:'documentation'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1265
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1266
version
7416
4ca9990e4e74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7412
diff changeset
  1267
    ^ '$Header: /cvs/stx/stx/libbasic/ArithmeticValue.st,v 1.56 2003-06-17 22:45:36 cg Exp $'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1268
! !
6858
13919a7544b6 raisedToInteger pushed up
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1269
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1270
ArithmeticValue initialize!