--- a/Float.st Mon Jun 11 12:54:51 2007 +0200
+++ b/Float.st Mon Jun 11 12:55:57 2007 +0200
@@ -9,12 +9,12 @@
other person. No title to or ownership of the software is
hereby transferred.
"
-
"{ Package: 'stx:libbasic' }"
LimitedPrecisionReal variableByteSubclass:#Float
instanceVariableNames:''
- classVariableNames:'DefaultPrintFormat Pi E'
+ classVariableNames:'DefaultPrintFormat Pi E Halfpi HalfpiNegative Twopi
+ RadiansPerDegree Ln2 Ln10 Sqrt2'
poolDictionaries:''
category:'Magnitude-Numbers'
!
@@ -460,7 +460,20 @@
!Float class methodsFor:'class initialization'!
initialize
- DefaultPrintFormat := '.6' "/ 6 valid digits
+ DefaultPrintFormat := '.6'. "/ 6 valid digits
+ Pi := 3.14159265358979323846264338327950288419716939937510582097494459.
+ Halfpi := Pi / 2.0.
+ HalfpiNegative := Halfpi negated.
+ Twopi := Pi * 2.0.
+ E := 2.7182818284590452353602874713526625.
+ Sqrt2 := 1.41421356237309504880168872420969808.
+ RadiansPerDegree := Pi / 180.0.
+ Ln2 := 0.69314718055994530941723212145817657.
+ Ln10 := 10.0 ln.
+
+ "
+ self initialize
+ "
"
DefaultPrintFormat := '.9'.
@@ -469,6 +482,8 @@
DefaultPrintFormat := '.6'.
Float pi printString.
"
+
+ "Modified: / 07-06-2007 / 21:17:53 / cg"
! !
!Float class methodsFor:'constants'!
@@ -506,6 +521,15 @@
^ 2.7182818284590452353602874713526625
!
+ln2
+ "/ dont expect this many valid digits on all machines;
+ "/ The actual precision is very CPU specific.
+
+ ^ 0.69314718055994530941723212145817657.
+
+ "Created: / 07-06-2007 / 21:11:55 / cg"
+!
+
pi
"return the constant pi as Float"
@@ -517,6 +541,15 @@
"Modified: 23.4.1996 / 09:27:02 / cg"
!
+sqrt2
+ "/ dont expect this many valid digits on all machines;
+ "/ The actual precision is very CPU specific.
+
+ ^ 1.41421356237309504880168872420969808
+
+ "Created: / 07-06-2007 / 21:12:33 / cg"
+!
+
unity
"return the neutral element for multiplication (1.0) as Float"
@@ -533,6 +566,22 @@
"Modified: 23.4.1996 / 09:27:15 / cg"
! !
+!Float class methodsFor:'croquet'!
+
+decodeFromIslandCopierStream: byteStream
+ | lit value |
+ value := Float new.
+ byteStream nextBytes: 8 into:value startingAt:1.
+
+"/ lit := byteStream next: 8.
+"/ value := 0 asFloat.
+"/ value basicAt: 1 put: (lit unsignedLongAt: 1 bigEndian: true).
+"/ value basicAt: 2 put: (lit unsignedLongAt: 5 bigEndian: true).
+ ^value
+
+ "Created: / 09-06-2007 / 17:16:07 / cg"
+! !
+
!Float class methodsFor:'queries'!
exponentCharacter
@@ -1150,6 +1199,7 @@
^ super ~= aNumber
! !
+
!Float methodsFor:'mathematical functions'!
exp
@@ -2107,6 +2157,25 @@
"Modified: / 16.11.2001 / 14:14:22 / cg"
!
+arcTan: denominator
+ (self = 0.0) ifTrue: [
+ (denominator > 0.0)
+ ifTrue: [ ^ 0 ]
+ ifFalse: [ ^ Pi ]
+ ].
+ (denominator = 0.0) ifTrue: [
+ (self > 0.0)
+ ifTrue: [ ^ Halfpi ]
+ ifFalse: [ ^ HalfpiNegative ]
+ ].
+ (denominator > 0)
+ ifTrue: [ ^ (self / denominator) arcTan ]
+ ifFalse: [ ^ ((self / denominator) arcTan) + Pi ]
+
+ "Created: / 07-06-2007 / 21:10:32 / cg"
+ "Modified: / 11-06-2007 / 12:58:34 / cg"
+!
+
arcTanh
"return the hyperbolic arctangent of the receiver."
@@ -2579,7 +2648,7 @@
!Float class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.163 2006-08-23 14:06:11 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.164 2007-06-11 10:55:57 cg Exp $'
! !
Float initialize!