added:
authorStefan Vogel <sv@exept.de>
Mon, 16 Apr 2012 23:57:50 +0200
changeset 14105 c19e70d239f1
parent 14104 2c06d704086a
child 14106 900bb7bce82f
added: #getFPUControl #setFPUControl changed: #initialize
Float.st
--- a/Float.st	Mon Apr 16 20:03:49 2012 +0200
+++ b/Float.st	Mon Apr 16 23:57:50 2012 +0200
@@ -470,18 +470,22 @@
 !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:[
+        self setFPUControl.
+        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
     "
 
@@ -576,6 +580,42 @@
     "Modified: 23.4.1996 / 09:27:15 / cg"
 ! !
 
+!Float class methodsFor:'misc'!
+
+getFPUControl
+    "get the fpu control word."
+
+%{
+#ifdef __BORLANDC__
+    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
@@ -648,7 +688,6 @@
     ^ 2 "must be careful here, whenever ST/X is used on VAX or a 370"
 ! !
 
-
 !Float methodsFor:'arithmetic'!
 
 * aNumber
@@ -1432,7 +1471,6 @@
     "Modified: / 16.11.2001 / 14:14:43 / cg"
 ! !
 
-
 !Float methodsFor:'printing & storing'!
 
 printString
@@ -1839,7 +1877,6 @@
     "
 ! !
 
-
 !Float methodsFor:'testing'!
 
 isFinite
@@ -2736,11 +2773,11 @@
 !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.177 2012-04-16 21:57:50 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.177 2012-04-16 21:57:50 stefan Exp $'
 ! !
 
 Float initialize!