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