MetaNumber.st
author Claus Gittinger <cg@exept.de>
Sat, 06 Jun 2015 14:42:18 +0200
changeset 18452 5724547da8de
parent 7436 077eb3b8f2c0
child 17711 39faaaf888b4
child 18831 86e8f2bd201b
permissions -rw-r--r--
class: UtcTimestamp comment/format in: #utcOffset
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7436
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2003 by eXept Software AG
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"{ Package: 'stx:libbasic' }"
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
Number subclass:#MetaNumber
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	instanceVariableNames:''
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	classVariableNames:''
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	poolDictionaries:''
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	category:'Magnitude-Numbers'
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!MetaNumber class methodsFor:'documentation'!
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
copyright
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
"
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
 COPYRIGHT (c) 2003 by eXept Software AG
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
              All Rights Reserved
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 This software is furnished under a license and may be used
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 other person.  No title to or ownership of the software is
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 hereby transferred.
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
"
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
documentation
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
"
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    Common behavior for metaNumbers (INF, NaN).
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    [author:]
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
        Claus Gittinger
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    [see also:]
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
        Number Infinity NotANumber
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
        Float ShortFloat Fraction FixedPoint Integer Complex
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
        FloatArray DoubleArray                                                                         
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
"
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
! !
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
!MetaNumber methodsFor:'coercing & converting'!
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
asFloat
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    ^ self class
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
        raise:#domainErrorSignal
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
        receiver:self
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
        selector:#asFloat
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
        arguments:#()
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
        errorString:'Cannot represent non-finite as float'.
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
!
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
asFraction
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    ^ self class
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
        raise:#domainErrorSignal
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
        receiver:self
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
        selector:#asFraction
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
        arguments:#()
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
        errorString:'Cannot represent non-finite as fraction'.
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
!
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
asInteger
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    ^ self class
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
        raise:#domainErrorSignal
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
        receiver:self
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
        selector:#asInteger
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
        arguments:#()
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
        errorString:'Cannot represent non-finite as integer'.
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
!
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
asLargeFloat
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    ^ self class
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
        raise:#domainErrorSignal
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
        receiver:self
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
        selector:#asLargeFloat
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
        arguments:#()
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
        errorString:'Cannot represent non-finite as float'.
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
!
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
asLongFloat
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    ^ self class
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
        raise:#domainErrorSignal
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
        receiver:self
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
        selector:#asLongFloat
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
        arguments:#()
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
        errorString:'Cannot represent non-finite as float'.
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
!
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
asShortFloat
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    ^ self class
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
        raise:#domainErrorSignal
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
        receiver:self
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
        selector:#asShortFloat
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
        arguments:#()
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
        errorString:'Cannot represent non-finite as float'.
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
!
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
coerce:aNumber
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    ^ aNumber asMetaNumber
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
!
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
generality
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    "NaN, INF etc. are more general than scalars, but not more general than
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
     vectors (e.g. Points)"
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    ^ 105
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
! !
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
!MetaNumber class methodsFor:'documentation'!
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
version
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    ^ '$Header: /cvs/stx/stx/libbasic/MetaNumber.st,v 1.1 2003-06-21 10:12:21 cg Exp $'
077eb3b8f2c0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
! !