#DOCUMENTATION by cg
class: Number
added: #epsilonForCloseTo
class: Number class
category of:
#epsilon
#epsilonForCloseTo
--- a/Number.st Mon Jun 10 21:23:25 2019 +0200
+++ b/Number.st Mon Jun 10 21:24:01 2019 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
@@ -249,7 +247,7 @@
it allows for prefixed + and also allows missing fractional part after eE.
It supports 0x, 0o and 0b prefixes (hex, octal and binary)
and the regular Smalltalk radix prefix xr.
- If also allows for strings like '1.0×1015' to be read (as 1E+15).
+ If also allows for strings like '1.0×1015' to be read (as 1E+15).
It also allows garbage after the number - i.e. it reads what it can.
See #fromString: , which is more strict and does not allow garbage at the end.
@@ -438,7 +436,7 @@
scale:(scale ? mantissaAndScale third).
].
] ifFalse:[
- (nextChar == $×) ifTrue:[
+ (nextChar == $×) ifTrue:[
(((nextChar := str nextPeek) == $1)
and:[ ((nextChar := str nextPeek) == $0) ]
) ifTrue:[
@@ -740,28 +738,6 @@
"Created: / 06-06-2019 / 16:58:50 / Claus Gittinger"
!
-epsilon
- "return the maximum relative spacing of instances of mySelf
- (i.e. the value-delta of the least significant bit)"
-
- ^ self subclassResponsibility
-!
-
-epsilonForCloseTo
- "return the epsilon used in the closeTo: comparison.
- (useful would be something like self epsilon or epsilon*10,
- but for Squeak compatibility.... - sigh)"
-
- ^ 0.0001
-
- "
- Float epsilon
- ShortFloat epsilon
- Float epsilon10
- ShortFloat epsilon10
- "
-!
-
i
"return the imaginary unit i"
@@ -985,6 +961,7 @@
"
! !
+
!Number class methodsFor:'private'!
readMantissaAndScaleFrom:aStream radix:radix
@@ -1073,6 +1050,28 @@
!Number class methodsFor:'queries'!
+epsilon
+ "return the maximum relative spacing of instances of mySelf
+ (i.e. the value-delta of the least significant bit)"
+
+ ^ self subclassResponsibility
+!
+
+epsilonForCloseTo
+ "return the epsilon used in the closeTo: comparison.
+ (useful would be something like self epsilon or epsilon*10,
+ but for Squeak compatibility.... - sigh)"
+
+ ^ 0.0001
+
+ "
+ Float epsilon
+ ShortFloat epsilon
+ Float epsilon10
+ ShortFloat epsilon10
+ "
+!
+
isAbstract
"Return if this class is an abstract class.
True is returned for Number here; false for subclasses.
@@ -1081,6 +1080,7 @@
^ self == Number
! !
+
!Number methodsFor:'Compatibility-Squeak'!
asSmallAngleDegrees
@@ -1220,6 +1220,19 @@
"Modified: / 02-08-2010 / 13:27:22 / cg"
!
+epsilonForCloseTo
+ "return the epsilon used in the closeTo: comparison."
+
+ ^ self class epsilonForCloseTo
+
+ "
+ 1.0 epsilon
+ 10 asShortFloat epsilon
+ "
+
+ "Created: / 10-06-2019 / 21:20:18 / Claus Gittinger"
+!
+
isAlmostEqualTo:aNumber nEpsilon:nE
"return true, if the argument, aNumber represents almost the same numeric value
as the receiver, false otherwise.
@@ -1987,6 +2000,10 @@
^ self
! !
+
+
+
+
!Number methodsFor:'printing & storing'!
displayOn:aGCOrStream
@@ -3629,6 +3646,7 @@
"
! !
+
!Number class methodsFor:'documentation'!
version