Float.st
branchjv
changeset 17940 985e22966acb
parent 17911 a99f15c5efa5
child 17966 8b5df02e171f
--- a/Float.st	Fri Apr 13 15:03:30 2012 +0100
+++ b/Float.st	Sat May 05 22:58:24 2012 +0100
@@ -471,18 +471,21 @@
 !Float class methodsFor:'class initialization'!
 
 initialize
-    DefaultPrintFormat := '.15'.  "/ print 15 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.
+    Pi isNil ifTrue:[
+        DefaultPrintFormat := '.15'.  "/ print 15 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.
+    ].
 
     "
+     Pi := nil.
      self initialize
     "
 
@@ -577,6 +580,44 @@
     "Modified: 23.4.1996 / 09:27:15 / cg"
 ! !
 
+!Float class methodsFor:'misc'!
+
+getFPUControl
+    "get the fpu control word."
+
+%{
+#ifdef __BORLANDC__
+    unsigned int _control87();
+
+    int result = _control87(0, 0);
+    RETURN(__MKSMALLINT(result));
+#endif
+%}
+
+    "
+        self getFPUControl
+    "
+!
+
+setFPUControl
+    "set the fpu control word.
+     We want 64 bit precision for long double here"
+
+%{
+#ifdef __BORLANDC__
+#include <float.h>
+
+    // Set precision to long double / 64bit
+    int result = _control87(PC_64, MCW_PC);
+    RETURN(__MKSMALLINT(result));
+#endif
+%}
+
+    "
+        self setFPUControl
+    "
+! !
+
 !Float class methodsFor:'queries'!
 
 exponentCharacter
@@ -649,7 +690,6 @@
     ^ 2 "must be careful here, whenever ST/X is used on VAX or a 370"
 ! !
 
-
 !Float methodsFor:'arithmetic'!
 
 * aNumber
@@ -1433,7 +1473,6 @@
     "Modified: / 16.11.2001 / 14:14:43 / cg"
 ! !
 
-
 !Float methodsFor:'printing & storing'!
 
 printString
@@ -1840,7 +1879,6 @@
     "
 ! !
 
-
 !Float methodsFor:'testing'!
 
 isFinite
@@ -2737,15 +2775,15 @@
 !Float class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.176 2010/11/23 13:35:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.179 2012/04/17 20:36:48 stefan Exp $'
 !
 
 version_CVS
-    ^ '§Header: /cvs/stx/stx/libbasic/Float.st,v 1.176 2010/11/23 13:35:52 cg Exp §'
+    ^ '§Header: /cvs/stx/stx/libbasic/Float.st,v 1.179 2012/04/17 20:36:48 stefan Exp §'
 !
 
 version_SVN
-    ^ '$Id: Float.st 10761 2012-01-19 11:46:00Z vranyj1 $'
+    ^ '$Id: Float.st 10807 2012-05-05 21:58:24Z vranyj1 $'
 ! !
 
 Float initialize!