Number.st
author tm
Wed, 19 Aug 1998 12:54:40 +0200
changeset 3770 6db2b6d5d17d
parent 3716 e7904bd50d9d
child 3900 c3bc76767cfc
permissions -rw-r--r--
comment
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1988 by Claus Gittinger
3770
6db2b6d5d17d comment
tm
parents: 3716
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
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
ArithmeticValue subclass:#Number
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    14
        instanceVariableNames:''
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    15
        classVariableNames:''
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    16
        poolDictionaries:''
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    17
        category:'Magnitude-Numbers'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
1892
d3564145c15c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
    20
!Number class methodsFor:'documentation'!
88
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    21
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    22
copyright
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    23
"
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    24
 COPYRIGHT (c) 1988 by Claus Gittinger
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    25
              All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    26
88
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    27
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    28
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    30
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    31
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    32
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    33
"
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    34
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    35
88
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    36
documentation
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    37
"
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    38
    abstract superclass for all kinds of numbers
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
    39
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
    40
    [author:]
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    41
        Claus Gittinger
1628
da30f2f41db7 comment
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
    42
da30f2f41db7 comment
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
    43
    [see also:]
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    44
        Integer LargeInteger SmallInteger
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    45
        LimitedPrecisionReal Float ShortFloat
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    46
        Fraction FixedPoint
88
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    47
"
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    48
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    49
1892
d3564145c15c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
    50
!Number class methodsFor:'instance creation'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    51
3060
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    52
fromString:aString
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    53
    "for compatibility with other smalltalks - same as #readFrom:"
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    54
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    55
    ^ self readFrom:aString
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    56
3716
e7904bd50d9d comment
Claus Gittinger <cg@exept.de>
parents: 3634
diff changeset
    57
    "
e7904bd50d9d comment
Claus Gittinger <cg@exept.de>
parents: 3634
diff changeset
    58
     Number fromString:'12345'
e7904bd50d9d comment
Claus Gittinger <cg@exept.de>
parents: 3634
diff changeset
    59
     '12345' asNumber
e7904bd50d9d comment
Claus Gittinger <cg@exept.de>
parents: 3634
diff changeset
    60
    "
e7904bd50d9d comment
Claus Gittinger <cg@exept.de>
parents: 3634
diff changeset
    61
e7904bd50d9d comment
Claus Gittinger <cg@exept.de>
parents: 3634
diff changeset
    62
    "Modified: / 3.8.1998 / 20:05:11 / cg"
3060
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    63
!
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    64
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    65
fromString:aString onError:exceptionBlock
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    66
    "for compatibility with other smalltalks - same as #readFrom:"
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    67
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    68
    ^ self readFrom:aString onError:exceptionBlock
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    69
3716
e7904bd50d9d comment
Claus Gittinger <cg@exept.de>
parents: 3634
diff changeset
    70
    "
e7904bd50d9d comment
Claus Gittinger <cg@exept.de>
parents: 3634
diff changeset
    71
     Number fromString:'12345' onError:0
e7904bd50d9d comment
Claus Gittinger <cg@exept.de>
parents: 3634
diff changeset
    72
     Number fromString:'fooBarBaz' onError:0
e7904bd50d9d comment
Claus Gittinger <cg@exept.de>
parents: 3634
diff changeset
    73
    "
e7904bd50d9d comment
Claus Gittinger <cg@exept.de>
parents: 3634
diff changeset
    74
e7904bd50d9d comment
Claus Gittinger <cg@exept.de>
parents: 3634
diff changeset
    75
    "Modified: / 3.8.1998 / 20:05:34 / cg"
3060
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    76
!
0faf242e1142 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    77
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    78
readFrom:aStringOrStream onError:exceptionBlock
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    79
    "return the next Number from the (character-)stream aStream;
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 93
diff changeset
    80
     skipping all whitespace first; return the value of exceptionBlock,
40ca7cc6fb9c *** empty log message ***
claus
parents: 93
diff changeset
    81
     if no number can be read."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    82
973
5bb2473bf1ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
    83
    ErrorSignal handle:[:ex |
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    84
        ^ exceptionBlock value
339
claus
parents: 329
diff changeset
    85
    ] do:[
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    86
        |str nextChar radix value negative signExp freakOut|
1701
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1635
diff changeset
    87
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    88
        str := aStringOrStream readStream.
1701
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1635
diff changeset
    89
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    90
        nextChar := str skipSeparators.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    91
        nextChar isNil ifTrue:[^ exceptionBlock value].
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
    92
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    93
        freakOut := [^ exceptionBlock value].
339
claus
parents: 329
diff changeset
    94
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    95
        (nextChar == $-) ifTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    96
            negative := true.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    97
            str next.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    98
            nextChar := str peekOrNil
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
    99
        ] ifFalse:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   100
            negative := false.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   101
            (nextChar == $+) ifTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   102
                str next.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   103
                nextChar := str peekOrNil
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   104
            ]
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   105
        ].
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   106
        nextChar isDigit ifFalse:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   107
            ^ exceptionBlock value.
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   108
"/          value := super readFrom:str.
339
claus
parents: 329
diff changeset
   109
"/          negative ifTrue:[value := value negated].
claus
parents: 329
diff changeset
   110
"/          ^ value
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   111
        ].
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   112
        value := Integer readFrom:str radix:10 onError:freakOut.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   113
        nextChar := str peekOrNil.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   114
        ((nextChar == $r) or:[ nextChar == $R]) ifTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   115
            str next.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   116
            radix := value.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   117
            value := Integer readFrom:str radix:radix onError:freakOut.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   118
        ] ifFalse:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   119
            radix := 10
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   120
        ].
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   121
        (nextChar == $.) ifTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   122
            str next.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   123
            nextChar := str peekOrNil.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   124
            (nextChar notNil and:[nextChar isDigitRadix:radix]) ifTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   125
                value := value asFloat 
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   126
                         + (Number readMantissaFrom:str radix:radix).
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   127
                nextChar := str peekOrNil
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   128
            ]
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   129
        ].
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   130
        ((nextChar == $e) or:[nextChar == $E]) ifTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   131
            str next.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   132
            nextChar := str peekOrNil.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   133
            signExp := 1.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   134
            (nextChar == $+) ifTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   135
                str next.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   136
                nextChar := str peekOrNil.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   137
            ] ifFalse:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   138
                (nextChar == $-) ifTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   139
                    str next.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   140
                    nextChar := str peekOrNil.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   141
                    signExp := -1
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   142
                ]
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   143
            ].
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   144
            (nextChar notNil and:[(nextChar isDigitRadix:radix)]) ifTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   145
                value := value asFloat 
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   146
                         * (10.0 raisedToInteger:
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   147
                                    ((Integer readFrom:str radix:radix onError:freakOut) * signExp))
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   148
            ]
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   149
        ].
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   150
        negative ifTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   151
            ^ value negated
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   152
        ].
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   153
        ^ value
339
claus
parents: 329
diff changeset
   154
    ]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   155
329
claus
parents: 325
diff changeset
   156
    "
claus
parents: 325
diff changeset
   157
     Number readFrom:(ReadStream on:'54.32e-01')      
claus
parents: 325
diff changeset
   158
     Number readFrom:(ReadStream on:'12345678901234567890') 
claus
parents: 325
diff changeset
   159
     Number readFrom:(ReadStream on:'16rAAAAFFFFAAAAFFFF') 
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   160
     Number readFrom:'16rAAAAFFFFAAAAFFFF' 
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   161
     Number readFrom:'0.000001'  
329
claus
parents: 325
diff changeset
   162
     '+00000123.45' asNumber  
claus
parents: 325
diff changeset
   163
    "
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   164
3375
7c64da3964e4 faster conversion from string (due to slow #pastEnd)
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   165
    "Modified: / 14.4.1998 / 19:22:50 / cg"
296
754358c5508a *** empty log message ***
claus
parents: 293
diff changeset
   166
!
754358c5508a *** empty log message ***
claus
parents: 293
diff changeset
   167
754358c5508a *** empty log message ***
claus
parents: 293
diff changeset
   168
readSmalltalkSyntaxFrom:aStream
754358c5508a *** empty log message ***
claus
parents: 293
diff changeset
   169
    "ST-80 compatibility (thanks to a note from alpha testers)
754358c5508a *** empty log message ***
claus
parents: 293
diff changeset
   170
     read and return the next Number in smalltalk syntax from the 
329
claus
parents: 325
diff changeset
   171
     (character-)stream aStream."
claus
parents: 325
diff changeset
   172
3613
75629df7f224 fixed readSmalltalkSyntax (dont read behind number)
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
   173
    ^ Scanner scanNumberFrom:aStream
75629df7f224 fixed readSmalltalkSyntax (dont read behind number)
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
   174
"/    ^ Compiler evaluate:aStream compile:false "/ self readFrom:aStream.
296
754358c5508a *** empty log message ***
claus
parents: 293
diff changeset
   175
329
claus
parents: 325
diff changeset
   176
    "
claus
parents: 325
diff changeset
   177
     Number readSmalltalkSyntaxFrom:(ReadStream on:'54.32e-01')    
claus
parents: 325
diff changeset
   178
     Number readSmalltalkSyntaxFrom:(ReadStream on:'12345678901234567890')
claus
parents: 325
diff changeset
   179
     Number readSmalltalkSyntaxFrom:(ReadStream on:'16rAAAAFFFFAAAAFFFF')
claus
parents: 325
diff changeset
   180
     Number readSmalltalkSyntaxFrom:(ReadStream on:'(1/10)') 
claus
parents: 325
diff changeset
   181
     Number readFrom:(ReadStream on:'(1/10)') 
claus
parents: 325
diff changeset
   182
     Number readSmalltalkSyntaxFrom:(ReadStream on:'+00000123.45')  
claus
parents: 325
diff changeset
   183
     Number readFrom:(ReadStream on:'+00000123.45')  
claus
parents: 325
diff changeset
   184
    "
3613
75629df7f224 fixed readSmalltalkSyntax (dont read behind number)
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
   185
75629df7f224 fixed readSmalltalkSyntax (dont read behind number)
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
   186
    "Modified: / 18.6.1998 / 23:02:57 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   187
! !
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   188
1892
d3564145c15c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   189
!Number class methodsFor:'error reporting'!
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   190
3613
75629df7f224 fixed readSmalltalkSyntax (dont read behind number)
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
   191
raise:aSignalSymbol receiver:someNumber selector:sel arg:arg errorString:text 
3394
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   192
    "ST-80 compatible signal raising. Provided for PD numeric classes"
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   193
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   194
    |msg|
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   195
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   196
    msg := MessageSend
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   197
                receiver:someNumber
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   198
                selector:sel
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   199
                arguments:(Array with:arg).
3394
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   200
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   201
    ^ (self perform:aSignalSymbol)
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   202
         raiseRequestWith:msg 
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   203
         errorString:text 
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   204
         in:thisContext sender
3394
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   205
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   206
    "
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   207
     Number 
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   208
        raise:#domainErrorSignal
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   209
        receiver:1.0
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   210
        selector:#sin
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   211
        arg:nil
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   212
        errorString:'foo bar test'
3394
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   213
    "
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   214
!
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   215
3613
75629df7f224 fixed readSmalltalkSyntax (dont read behind number)
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
   216
raise:aSignalSymbol receiver:someNumber selector:sel arguments:argArray errorString:text 
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   217
    "ST-80 compatible signal raising. Provided for PD numeric classes"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   218
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   219
    |msg|
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   220
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   221
    msg := MessageSend
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   222
                receiver:someNumber
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   223
                selector:sel
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   224
                arguments:argArray.
3394
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   225
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   226
    ^ (self perform:aSignalSymbol)
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   227
         raiseRequestWith:msg 
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   228
         errorString:text 
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   229
         in:thisContext sender
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   230
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   231
    "
3394
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   232
     Number 
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   233
        raise:#domainErrorSignal
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   234
        receiver:1.0
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   235
        selector:#sin
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   236
        arg:nil
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   237
        errorString:'foo bar test'
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   238
    "
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   239
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   240
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   241
raise:aSignalSymbol receiver:someNumber selector:sel errorString:text 
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   242
    "ST-80 compatible signal raising. Provided for PD numeric classes"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   243
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   244
    |msg|
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   245
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   246
    msg := MessageSend
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   247
                receiver:someNumber
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   248
                selector:sel
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   249
                arguments:#().
3394
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   250
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   251
    ^ (self perform:aSignalSymbol)
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   252
         raiseRequestWith:msg 
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   253
         errorString:text 
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   254
         in:thisContext sender
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   255
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   256
    "
3394
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   257
     Number 
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   258
        raise:#domainErrorSignal
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   259
        receiver:1.0
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   260
        selector:#foo 
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   261
        errorString:'foo bar test'
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   262
    "
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   263
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   264
1892
d3564145c15c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   265
!Number class methodsFor:'private'!
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   266
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   267
readMantissaFrom:aStream radix:radix
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   268
    "helper for readFrom: -
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   269
     return the mantissa from the (character-)stream aStream;
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   270
     no whitespace-skipping; error if no number available"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   271
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   272
    |nextChar value factor|
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   273
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   274
    value := 0.0.
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   275
    factor := 1.0 / radix.
3375
7c64da3964e4 faster conversion from string (due to slow #pastEnd)
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   276
    nextChar := aStream peekOrNil.
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   277
    [nextChar notNil and:[nextChar isDigitRadix:radix]] whileTrue:[
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   278
        value := value + (nextChar digitValue * factor).
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   279
        factor := factor / radix.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   280
        aStream next.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   281
        nextChar := aStream peekOrNil
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   282
    ].
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   283
    ^ value
3375
7c64da3964e4 faster conversion from string (due to slow #pastEnd)
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   284
7c64da3964e4 faster conversion from string (due to slow #pastEnd)
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   285
    "Modified: / 14.4.1998 / 18:47:47 / cg"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   286
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   287
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   288
!Number methodsFor:'coercing'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   289
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   290
coerce:aNumber
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   291
    "return aNumber converted into receivers type"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   292
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   293
    ^ self subclassResponsibility
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   294
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   295
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   296
generality
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   297
    "return the generality value - see ArithmeticValue>>retry:coercing:"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   298
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   299
    ^ 40
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   300
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   301
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   302
!Number methodsFor:'converting'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   303
3634
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   304
% aNumber 
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   305
    "Return a complex number with the receiver as the real part and 
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   306
     aNumber as the imaginary part"
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   307
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   308
    ^ Complex real:self imaginary:aNumber
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   309
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   310
    "Modified: / 9.7.1998 / 10:18:12 / cg"
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   311
!
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   312
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   313
@ aNumber
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   314
    "return a Point with the receiver as x-coordinate and the argument
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   315
     as y-coordinate"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   316
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   317
%{  /* NOCONTEXT */
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   318
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   319
    /*
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   320
     * I cannot tell if this special code is worth anything
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   321
     */
3394
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   322
    if (__CanDoQuickNew(sizeof(struct __point))) {      /* OBJECT ALLOCATION */
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   323
        OBJ newPoint;
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   324
        int spc;
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   325
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   326
        __qCheckedAlignedNew(newPoint, sizeof(struct __point));
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   327
        __InstPtr(newPoint)->o_class = @global(Point);
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   328
        __PointInstPtr(newPoint)->p_x = self;
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   329
        __PointInstPtr(newPoint)->p_y = aNumber;
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   330
        if (! __bothSmallInteger(self, aNumber)) {
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   331
            spc = __qSpace(newPoint);
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   332
            __STORE_SPC(newPoint, aNumber, spc);
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   333
            __STORE_SPC(newPoint, self, spc);
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   334
        }
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   335
        RETURN ( newPoint );
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   336
    }
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   337
%}
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   338
.
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   339
    ^ Point x:self y:aNumber
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   340
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   341
3634
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   342
asComplex
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   343
    "Return a complex number with the receiver as the real part and 
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   344
     zero as the imaginary part"
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   345
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   346
    ^ Complex fromReal:self
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   347
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   348
    "Modified: / 9.7.1998 / 10:18:16 / cg"
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   349
!
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   350
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   351
asPoint
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   352
    "return a new Point with the receiver as all coordinates;  
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   353
     often used to supply the same value in two dimensions, as with 
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   354
     symmetrical gridding or scaling."
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   355
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   356
%{  /* NOCONTEXT */
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   357
3394
33e8273b95f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3375
diff changeset
   358
    if (__CanDoQuickNew(sizeof(struct __point))) {      /* OBJECT ALLOCATION */
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   359
        OBJ newPoint;
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   360
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   361
        __qCheckedAlignedNew(newPoint, sizeof(struct __point));
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   362
        __InstPtr(newPoint)->o_class = @global(Point);
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   363
        __PointInstPtr(newPoint)->p_x = self;
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   364
        __PointInstPtr(newPoint)->p_y = self;
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   365
        __STORE(newPoint, self);
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   366
        RETURN ( newPoint );
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   367
    }
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   368
%}.
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   369
    ^ Point x:self y:self
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   370
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   371
2416
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   372
decodeAsLiteralArray
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   373
    "given a literalEncoding in the receiver,
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   374
     create & return the corresponding object.
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   375
     The inverse operation to #literalArrayEncoding."
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   376
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   377
    ^ self
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   378
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   379
    "Created: 25.2.1997 / 19:17:06 / cg"
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   380
    "Modified: 25.2.1997 / 19:17:42 / cg"
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   381
!
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   382
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   383
degreesToRadians
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   384
    "interpreting the receiver as radians, return the degrees"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   385
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   386
    ^ (self * (Float pi)) / 180.0
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   387
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   388
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   389
literalArrayEncoding
1245
c8afea3d5af0 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
   390
    "encode myself as an array literal, from which a copy of the receiver
c8afea3d5af0 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
   391
     can be reconstructed with #decodeAsLiteralArray."
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   392
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   393
    ^ self
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   394
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   395
    "Modified: 1.9.1995 / 02:25:26 / claus"
1245
c8afea3d5af0 commentary
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
   396
    "Modified: 22.4.1996 / 13:00:27 / cg"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   397
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   398
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   399
radiansToDegrees
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   400
    "interpreting the receiver as degrees, return the radians"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   401
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   402
    ^ (self * 180.0) / (Float pi)
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   403
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   404
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   405
!Number methodsFor:'intervals'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   406
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   407
to:stop
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   408
    "return an interval from receiver up to the argument, incrementing by 1"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   409
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   410
    ^ Interval from:self to:stop
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   411
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   412
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   413
to:stop by:step
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   414
    "return an interval from receiver up to the argument, incrementing by step"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   415
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   416
    ^ Interval from:self to:stop by:step
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   417
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   418
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   419
!Number methodsFor:'iteration'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   420
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   421
timesRepeat:aBlock
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   422
    "evaluate the argument, aBlock self times"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   423
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   424
    |count|
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   425
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   426
    count := self.
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   427
    [count > 0] whileTrue:[
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   428
        aBlock value.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   429
        count := count - 1
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   430
    ]
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   431
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   432
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   433
to:stop by:incr do:aBlock
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   434
    "For each element of the interval from the receiver up to the argument stop, incrementing
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   435
     by step, evaluate aBlock passing the element as argument."
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   436
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   437
    |tmp|
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   438
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   439
    tmp := self.
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   440
    (incr > 0) ifTrue:[
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   441
        [tmp <= stop] whileTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   442
            aBlock value:tmp.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   443
            tmp := tmp+incr
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   444
        ]
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   445
    ] ifFalse:[
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   446
        [tmp >= stop] whileTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   447
            aBlock value:tmp.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   448
            tmp := tmp+incr
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   449
        ]
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   450
    ]
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   451
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   452
919
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   453
to:stop by:incr doWithBreak:aBlock
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   454
    "For each element of the interval from the receiver up to the argument stop, incrementing
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   455
     by step, evaluate aBlock passing the element as argument.
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   456
     Pass a break argument, to allow for premature exit of the loop."
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   457
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   458
    |tmp break|
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   459
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   460
    break := [^ self].
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   461
    tmp := self.
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   462
    (incr > 0) ifTrue:[
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   463
        [tmp <= stop] whileTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   464
            aBlock value:tmp value:break.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   465
            tmp := tmp+incr
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   466
        ]
919
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   467
    ] ifFalse:[
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   468
        [tmp >= stop] whileTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   469
            aBlock value:tmp value:break.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   470
            tmp := tmp+incr
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   471
        ]
919
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   472
    ]
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   473
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   474
    "
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   475
     1 to:100 by:5 doWithBreak:[:index :break |
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   476
        Transcript showCR:index printString.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   477
        index > 50 ifTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   478
            break value
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   479
        ].
919
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   480
     ]
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   481
    "
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   482
!
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   483
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   484
to:stop do:aBlock
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   485
    "For each element of the interval from the receiver up to the argument stop,
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   486
     evaluate aBlock, passing the number as argument."
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   487
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   488
    |tmp|
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   489
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   490
    tmp := self.
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   491
    [tmp <= stop] whileTrue:[
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   492
        aBlock value:tmp.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   493
        tmp := tmp+1
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   494
    ]
919
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   495
!
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   496
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   497
to:stop doWithBreak:aBlock
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   498
    "For each element of the interval from the receiver up to the argument stop,
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   499
     evaluate aBlock, passing the number as argument.
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   500
     Pass a break argument, to allow for premature exit of the loop."
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   501
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   502
    |tmp break|
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   503
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   504
    break := [^ self].
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   505
    tmp := self.
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   506
    [tmp <= stop] whileTrue:[
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   507
        aBlock value:tmp value:break.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   508
        tmp := tmp+1
919
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   509
    ]
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   510
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   511
    "
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   512
     1 to:10 doWithBreak:[:index :break |
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   513
        Transcript showCR:index printString.
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   514
        index > 5 ifTrue:[
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   515
            break value
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   516
        ].
919
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   517
     ]
d285a0816e54 added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   518
    "
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   519
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   520
3634
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   521
!Number methodsFor:'mathematical functions'!
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   522
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   523
conjugated
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   524
    "Return the complex conjugate of this Number."
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   525
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   526
    ^ self
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   527
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   528
    "Modified: / 9.7.1998 / 10:17:31 / cg"
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   529
!
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   530
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   531
imaginary
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   532
    "Return the imaginary part of this Number."
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   533
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   534
    ^ 0
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   535
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   536
    "Modified: / 9.7.1998 / 10:17:24 / cg"
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   537
!
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   538
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   539
real
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   540
    "Return the real part of this Number."
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   541
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   542
    ^ self
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   543
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   544
    "Modified: / 9.7.1998 / 10:17:17 / cg"
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   545
! !
bbf443dce0cf complex conversion stuff
Claus Gittinger <cg@exept.de>
parents: 3613
diff changeset
   546
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   547
!Number methodsFor:'printing & storing'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   548
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   549
storeOn:aStream
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   550
    "append a string for storing the receiver onto the argument,
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   551
     aStream - since numbers are literals,they store as they print."
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   552
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   553
    ^ self printOn:aStream
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   554
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   555
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   556
storeString
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   557
    "return a string for storing 
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   558
     - since numbers are literals, they store as they print."
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   559
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   560
    ^ self printString
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   561
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   562
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   563
!Number methodsFor:'testing'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   564
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   565
isLiteral
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   566
    "return true, if the receiver can be used as a literal
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   567
     (i.e. can be used in constant arrays)"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   568
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   569
    ^ true
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   570
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   571
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   572
isNumber
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   573
    "return true, if the receiver is a kind of number"
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   574
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   575
    ^ true
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   576
!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   577
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   578
isZero
1557
2c3c301cf48f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   579
    "return true, if the receiver is zero"
2c3c301cf48f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   580
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   581
    ^ self = 0
1557
2c3c301cf48f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   582
2c3c301cf48f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   583
    "Modified: 18.7.1996 / 12:40:49 / cg"
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   584
! !
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   585
1892
d3564145c15c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   586
!Number class methodsFor:'documentation'!
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   587
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   588
version
3770
6db2b6d5d17d comment
tm
parents: 3716
diff changeset
   589
    ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.47 1998-08-19 10:54:40 tm Exp $'
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   590
! !