| package | package := Package name: 'FloatComparePatch'. package paxVersion: 1; basicComment: ''. 'Copyright (c) <2005-2007> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.'. package methodNames add: #ArithmeticValue -> #compareWithFloat:; add: #ArithmeticValue -> #compareWithFraction:; add: #ArithmeticValue -> #compareWithInteger:; add: #Float -> #=; add: #Float -> #compareWithFraction:; add: #Float -> #compareWithInteger:; add: #Float -> #greaterThanFraction:; add: #Float -> #greaterThanInteger:; add: #Fraction -> #=; add: #Fraction -> #compareWithFloat:; add: #Fraction -> #greaterThanFloat:; add: #Integer -> #=; add: #Integer -> #compareWithFloat:; add: #Integer -> #greaterThanFloat:; yourself. package binaryGlobalNames: (Set new yourself). package globalAliases: (Set new yourself). package setPrerequisites: (IdentitySet new add: 'Object Arts\Dolphin\Base\Dolphin'; yourself). package! "Class Definitions"! "Global Aliases"! "Loose Methods"! !ArithmeticValue methodsFor! compareWithFloat: aFloat ^(self - aFloat) isZero! compareWithFraction: aFraction ^(self - aFraction) isZero! compareWithInteger: anInteger ^(self - anInteger) isZero! ! !ArithmeticValue categoriesFor: #compareWithFloat:!double dispatch!public! ! !ArithmeticValue categoriesFor: #compareWithFraction:!double dispatch!public! ! !ArithmeticValue categoriesFor: #compareWithInteger:!double dispatch!public! ! !Float methodsFor! = comperand "Answer whether the receiver is numerically equivalent to the argument, comperand (e.g. 1 = 1.0 is true). Primitive failure reasons: 0 - aNumber is not a SmallInteger or a Float. May also raise a floating point exception." ^comperand understandsArithmetic and: [comperand compareWithFloat: self] "^super = comperand"! compareWithFraction: aFraction ^self asTrueFraction = aFraction! compareWithInteger: anInteger ^self asTrueFraction = anInteger! greaterThanFraction: aFraction "Private - Answer whether the receiver is greater than the known Fraction, aFraction." ^aFraction < self asTrueFraction! greaterThanInteger: anInteger "Private - Answer whether the receiver is greater than the known Integer, anInteger." ^anInteger < self asTrueFraction! ! !Float categoriesFor: #=!comparing!public! ! !Float categoriesFor: #compareWithFraction:!double dispatch!public! ! !Float categoriesFor: #compareWithInteger:!double dispatch!public! ! !Float categoriesFor: #greaterThanFraction:!double dispatch!private! ! !Float categoriesFor: #greaterThanInteger:!double dispatch!private! ! !Fraction methodsFor! = comparand ^comparand understandsArithmetic and: [comparand compareWithFraction: self]! compareWithFloat: aFloat ^aFloat asTrueFraction = self! greaterThanFloat: aFloat "Private - Answer whether the receiver is greater than the known Float, aFloat" ^aFloat asTrueFraction < self! ! !Fraction categoriesFor: #=!comparing!public! ! !Fraction categoriesFor: #compareWithFloat:!double dispatch!public! ! !Fraction categoriesFor: #greaterThanFloat:!double dispatch!private! ! !Integer methodsFor! = comparand ^comparand understandsArithmetic and: [comparand compareWithInteger: self]! compareWithFloat: aFloat ^aFloat asTrueFraction = self! greaterThanFloat: aFloat "Private - Answer whether the receiver is greater than the known Float, aFloat." ^aFloat asTrueFraction < self! ! !Integer categoriesFor: #=!comparing!public! ! !Integer categoriesFor: #compareWithFloat:!double dispatch!public! ! !Integer categoriesFor: #greaterThanFloat:!double dispatch!private! ! "End of package definition"! "Source Globals"! "Classes"! "Binary Globals"!