From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:29:02 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <methods> Core.LimitedPrecisionReal class <category>constants access</category>
negativeInfinity "Answer floating point number representing negative infinity." ^self unity negated / self zero
notANumber "Answer a suitable IEEE Not-A-Number value." ^self zero / self zero
positiveInfinity "Answer floating point number representing positive infinity." ^self unity / self zero
</methods> <methods> Core.LimitedPrecisionReal class <category>accessing</category>
printStringForNegativeInfinity "Return the print string for positive infinity." ^'-' , self printStringForPositiveInfinity
printStringForNotANumber "Return the print string for positive infinity." ^'NaN'
printStringForPositiveInfinity "Return the print string for positive infinity." ^'INF'
</methods> <methods> Core.LimitedPrecisionReal class <category>constants access</category>
specialIEEENumberExponent "Answer the value of the exponent for floating-point Infinities and Not-a-Numbers. This is IEEE-specific. Note that the value is the value answered by the exponent primitive, not the actual bit-pattern." self subclassResponsibility
</methods> <methods> Core.LimitedPrecisionReal <category>testing</category>
isInfinity "Answer if the receiver is an IEEE infinity representation." ^self - self ~= 0 and: [self isNaN not]
</methods> <methods> Core.LimitedPrecisionReal <category>private</category>
isNaN "Answer if the receiver represents an IEEE NAN (Not a Number)." ^self ~= self
</methods> <methods> Core.LimitedPrecisionReal <category>testing</category>
isNegativeInfinity "Answer if the receiver represents an IEEE negative infinity." ^self < 0 and: [self - self ~= 0]
isPositiveInfinity "Answer if the receiver represents an IEEE positive infinity." ^self > 0 and: [self - self ~= 0]
</methods> <methods> Core.LimitedPrecisionReal <category>private</category>
isSpecialValue "Answer if the receiver represents an IEEE special value." ^self - self ~= 0
</methods> <methods> Core.LimitedPrecisionReal <category>printing</category>
printOn: aStream "Append to the argument, aStream, a literal form of the receiver using a reasonable number of significant digits." (self printSpecialsOn: aStream) ifFalse: [self printOn: aStream digits: self defaultNumberOfDigits]
printOn: aStream printPolicy: aNumberPrintPolicy "Append to the argument, aStream, a literal form of the receiver using a reasonable number of significant digits." (self printSpecialsOn: aStream) ifFalse: [self printOn: aStream digits: self defaultNumberOfDigits printPolicy: aNumberPrintPolicy]
printSpecialsOn: aStream "If the value is a speciall IEEE value, print it instead. Answer whether such was the case." self isSpecialValue ifFalse: [^false]. self isPositiveInfinity ifTrue: [aStream nextPutAll: self class printStringForPositiveInfinity. ^true]. self isNegativeInfinity ifTrue: [aStream nextPutAll: self class printStringForNegativeInfinity. ^true]. self isNaN ifTrue: [aStream nextPutAll: self class printStringForNotANumber. ^true]. self error: #UnknownSpecialValue << #dialogs >> 'unknown special value'
</methods> <methods> Core.Float class <category>constants access</category>
specialIEEENumberExponent "Answer the value of the exponent for single precision Infinities and Not-a-Numbers. This is IEEE-specific. Note that the value is the value answered by the exponent primitive, not the actual bit-pattern." ^128
</methods> <methods> Core.Float <category>comparing</category>
hash "Try to have a hash function that matches integers. The assumption is that for hashing, other rationals will convert themselves to Floats or Doubles to hash, so we'll have good hash functions for them." | truncated | self isSpecialValue ifTrue: [^self hashOfBytes]. truncated := self truncated. ^self = truncated ifTrue: [truncated hash] ifFalse: [^self hashOfBytes]
hashOfBytes "Answer the hash value calculated from the bytes that encode the receiver" | answer | answer := 0. 1 to: 4 do: [:each | | eachByteValue sBoxValue | eachByteValue := self basicAt: each. sBoxValue := self bretMulveySubstitutionBox30Bits at: eachByteValue + 1. answer := answer bitXor: sBoxValue ]. ^answer
</methods> <methods> Core.Float <category>truncation and round off</category>
truncated "Answer a SmallInteger equal to the value of the receiver without its fractional part. Fail if the truncated value cannot be represented as a SmallInteger. In that case, the code below will compute a LargeInteger truncated value." <primitive: 51> ^self isSpecialValue ifTrue: [self class raise: #domainErrorSignal receiver: self selector: #truncated errorString: #errCannotTruncate << #dialogs >> 'Cannot truncate Infinities or NaNs'] ifFalse: [| max | max := SmallInteger maxVal // 2 + 1. (self quo: max asFloat) * max + (self rem: max asFloat) truncated]
</methods> <methods> Core.Float <category>arithmetic</category>
\\ aNumber "Answer the receiver modulo aNumber; which is a Number m such that m has the same sign as aNumber, the absolute value of m is less than the absolute value of aNumber, and there exists an Integer k such that (k * aNumber + m) equals the receiver (e.g., 9\\4 = 1, -9\\4 = 3, 9\\-4 = -3, 0.9\\0.4 = 0.1)." ^[super \\ aNumber] on: DomainError do: [:ex | ex return: ((self isZero and: [aNumber isInfinity]) ifTrue: [self class zero] ifFalse: [self class notANumber])] "the inherited behavior ^self - (self // aNumber * aNumber) will break on IEEE specials when // tries to truncate "
</methods> <methods> Core.Number <category>testing</category>
isInfinity "Answer if the receiver is an IEEE infinity representation." ^false
isNegativeInfinity "Answer if the receiver is an IEEE negative infinity representation. " "Floats normally get this message, but need to handle case when an Integer sneaks in" ^false
isPositiveInfinity "Answer if the receiver is an IEEE positive infinity representation. " "Floats normally get this message, but need to handle case when an Integer sneaks in" ^false
</methods> <methods> Core.Double class <category>constants access</category>
specialIEEENumberExponent "Answer the value of the exponent for double precision Infinities and Not-a-Numbers. This is IEEE-specific. Note that the value is the value answered by the exponent primitive, not the actual bit-pattern." ^1024
</methods> <methods> Core.Double <category>comparing</category>
hash "Try to have a hash function that matches integers. The assumption is that for hashing, other rationals will convert themselves to Floats or Doubles to hash, so we'll have good hash functions for them." | truncated | self isSpecialValue ifTrue: [^self hashOfBytes]. truncated := self truncated. self = truncated ifTrue: [^truncated hash]. self canBeConvertedToFloat ifTrue: [^self asFloat hash]. ^self hashOfBytes
hashOfBytes "Answer the hash value calculated from the bytes that encode the receiver" | answer | answer := 0. 1 to: 8 do: [:each | | eachByteValue sBoxValue | eachByteValue := self basicAt: each. sBoxValue := self bretMulveySubstitutionBox30Bits at: eachByteValue + 1. answer := answer bitXor: sBoxValue ]. ^answer
</methods> <methods> Core.Double <category>truncation and round off</category>
truncated "Answer a SmallInteger equal to the value of the receiver without its fractional part. Fail if the truncated value cannot be represented as a SmallInteger. In that case, the code below will compute a LargeInteger truncated value" <primitive: 571> ^self isSpecialValue ifTrue: [self class raise: #domainErrorSignal receiver: self selector: #truncated errorString: #errCannotTruncate << #dialogs >> 'Cannot truncate Infinities or NaNs'] ifFalse: [| max quo rem | max := SmallInteger maxVal // 2 + 1. quo := self quo: max asDouble. rem := self - (quo * max asDouble). "in-line rem to avoid exponential number of quos" quo * max + rem truncated]
</methods> <methods> Core.Double <category>arithmetic</category>
\\ aNumber "Answer the receiver modulo aNumber; which is a Number m such that m has the same sign as aNumber, the absolute value of m is less than the absolute value of aNumber, and there exists an Integer k such that (k * aNumber + m) equals the receiver (e.g., 9\\4 = 1, -9\\4 = 3, 9\\-4 = -3, 0.9\\0.4 = 0.1)." ^[super \\ aNumber] on: DomainError do: [:ex | ex return: ((self isZero and: [aNumber isInfinity]) ifTrue: [self class zero] ifFalse: [self class notANumber])] "the inherited behavior ^self - (self // aNumber * aNumber) will break on IEEE specials when // tries to truncate "
</methods> <methods> Core.SmallDouble <category>testing</category>
isNegativeInfinity "Answer if the receiver represents an IEEE negative infinity. Since the SmallDouble range exclude NaN and Inf simply answer false." ^false
isPositiveInfinity "Answer if the receiver represents an IEEE positive infinity. Since the SmallDouble range exclude NaN and Inf simply answer false." ^false
</methods> <methods> Core.SmallDouble <category>private</category>
isSpecialValue "Answer if the receiver represents an IEEE special value. Since SmallDouble values exclude NaN and Inf simply answer false." ^false
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>Number</name> <environment>Core</environment> <super>Core.ArithmeticValue</super> <private>false</private> none <imports></imports> <category>Magnitude-Numbers</category> <attributes> <package>Magnitude-Numbers</package> </attributes> </class> <class> <name>LimitedPrecisionReal</name> <environment>Core</environment> <super>Core.Number</super> <private>false</private> none powersOfTwo <imports></imports> <category>Magnitude-Numbers</category> <attributes> <package>Magnitude-Numbers</package> </attributes> </class> <class> <name>Double</name> <environment>Core</environment> <super>Core.LimitedPrecisionReal</super> <private>false</private> bytes <imports></imports> <category>Magnitude-Numbers</category> <attributes> <package>Magnitude-Numbers</package> </attributes> </class> <class> <name>Float</name> <environment>Core</environment> <super>Core.LimitedPrecisionReal</super> <private>false</private> bytes <imports></imports> <category>Magnitude-Numbers</category> <attributes> <package>Magnitude-Numbers</package> </attributes> </class> <class> <name>SmallDouble</name> <environment>Core</environment> <super>Core.LimitedPrecisionReal</super> <private>false</private> immediate <imports></imports> <category>Magnitude-Numbers</category> <attributes> <package>Magnitude-Numbers</package> </attributes> </class>