QDouble.st
changeset 5309 3e482ee15d7f
parent 5308 d992975959ab
child 5310 0b6380408893
--- a/QDouble.st	Fri Nov 29 14:21:34 2019 +0100
+++ b/QDouble.st	Fri Nov 29 14:27:00 2019 +0100
@@ -2974,18 +2974,18 @@
      (returns approx. 200 bits of precision)"
 
     Ln10 isNil ifTrue:[
-        Ln10 := self d0: 2.302585092994045901e+00
-                     d1: -2.170756223382249351e-16
-                     d2: -9.984262454465776570e-33
-                     d3: -4.023357454450206379e-49
+	Ln10 := self d0: 2.302585092994045901e+00
+		     d1: -2.170756223382249351e-16
+		     d2: -9.984262454465776570e-33
+		     d3: -4.023357454450206379e-49
     ].
     ^ Ln10
 
     "
-     self ln10 printfPrintString:'%.61f' 
-        -> '2.3025850929940456840179914546843642076011014886287729760333279'
+     self ln10 printfPrintString:'%.61f'
+	-> '2.3025850929940456840179914546843642076011014886287729760333279'
      Wolfram says:
-            2.30258509299404568401799145468436420760110148862877297603332790096757260967735248023599720508959829834196778404228...
+	    2.30258509299404568401799145468436420760110148862877297603332790096757260967735248023599720508959829834196778404228...
     "
 
     "Created: / 12-06-2017 / 18:32:29 / cg"
@@ -3203,38 +3203,38 @@
 
 %{
     if (__isFloatLike(aNumber)) {
-        double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
-        double b = __floatVal(aNumber);
-        double c0, c1, c2, c3;
-        OBJ newQD;
-        int savedCV;
-
-        fpu_fix_start(&savedCV);
-        s_mul_qd(&c0, &c1, &c2, &c3, b, a[0], a[1], a[2], a[3]);
-        fpu_fix_end(&savedCV);
-        __qNew_qdReal(newQD, c0, c1, c2, c3);
-        RETURN( newQD );
+	double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
+	double b = __floatVal(aNumber);
+	double c0, c1, c2, c3;
+	OBJ newQD;
+	int savedCV;
+
+	fpu_fix_start(&savedCV);
+	s_mul_qd(&c0, &c1, &c2, &c3, b, a[0], a[1], a[2], a[3]);
+	fpu_fix_end(&savedCV);
+	__qNew_qdReal(newQD, c0, c1, c2, c3);
+	RETURN( newQD );
     }
     if (__isQDouble(aNumber)) {
-        double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
-        double *b = __QDoubleInstPtr(aNumber)->d_qDoubleValue;
-        double c0, c1, c2, c3;
-        OBJ newQD;
-        int savedCV;
-
-        fpu_fix_start(&savedCV);
-        qd_mul_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
-        fpu_fix_end(&savedCV);
-        __qNew_qdReal(newQD, c0, c1, c2, c3);
-        RETURN( newQD );
+	double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
+	double *b = __QDoubleInstPtr(aNumber)->d_qDoubleValue;
+	double c0, c1, c2, c3;
+	OBJ newQD;
+	int savedCV;
+
+	fpu_fix_start(&savedCV);
+	qd_mul_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
+	fpu_fix_end(&savedCV);
+	__qNew_qdReal(newQD, c0, c1, c2, c3);
+	RETURN( newQD );
     }
 %}.
     ^ aNumber productFromQDouble:self
 
     "
-     (QDouble fromFloat:1e20) * 2.0 
-     (QDouble fromFloat:1e20) * 1e20 
-     (QDouble fromFloat:1e20) * (QDouble fromFloat:1e20) 
+     (QDouble fromFloat:1e20) * 2.0
+     (QDouble fromFloat:1e20) * 1e20
+     (QDouble fromFloat:1e20) * (QDouble fromFloat:1e20)
      ((QDouble fromFloat:1e20) * (QDouble fromFloat:2.0)) asDoubleArray
      ((QDouble fromFloat:1e-20) * (QDouble fromFloat:2.0)) asDoubleArray
      ((QDouble fromFloat:2.0) * (QDouble fromFloat:2.0)) asDoubleArray
@@ -3291,30 +3291,30 @@
 
 %{
     if (__isFloatLike(aNumber)) {
-        double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
-        double b = __floatVal(aNumber);
-        double c0, c1, c2, c3;
-        OBJ newQD;
-        int savedCV;
-
-        fpu_fix_start(&savedCV);
-        qd_add_s(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], -b);
-        fpu_fix_end(&savedCV);
-        __qNew_qdReal(newQD, c0, c1, c2, c3);
-        RETURN( newQD );
+	double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
+	double b = __floatVal(aNumber);
+	double c0, c1, c2, c3;
+	OBJ newQD;
+	int savedCV;
+
+	fpu_fix_start(&savedCV);
+	qd_add_s(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], -b);
+	fpu_fix_end(&savedCV);
+	__qNew_qdReal(newQD, c0, c1, c2, c3);
+	RETURN( newQD );
     }
     if (__isQDouble(aNumber)) {
-        double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
-        double *b = __QDoubleInstPtr(aNumber)->d_qDoubleValue;
-        double c0, c1, c2, c3;
-        OBJ newQD;
-        int savedCV;
-
-        fpu_fix_start(&savedCV);
-        qd_sub_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
-        fpu_fix_end(&savedCV);
-        __qNew_qdReal(newQD, c0, c1, c2, c3);
-        RETURN( newQD );
+	double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
+	double *b = __QDoubleInstPtr(aNumber)->d_qDoubleValue;
+	double c0, c1, c2, c3;
+	OBJ newQD;
+	int savedCV;
+
+	fpu_fix_start(&savedCV);
+	qd_sub_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
+	fpu_fix_end(&savedCV);
+	__qNew_qdReal(newQD, c0, c1, c2, c3);
+	RETURN( newQD );
     }
 %}.
     ^ self + (aNumber negated)
@@ -3339,30 +3339,30 @@
 
 %{
     if (__isFloatLike(aNumber)) {
-        double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
-        double b = __floatVal(aNumber);
-        double c0, c1, c2, c3;
-        OBJ newQD;
-        int savedCV;
-
-        fpu_fix_start(&savedCV);
-        qd_div_s(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b);
-        fpu_fix_end(&savedCV);
-        __qNew_qdReal(newQD, c0, c1, c2, c3);
-        RETURN( newQD );
+	double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
+	double b = __floatVal(aNumber);
+	double c0, c1, c2, c3;
+	OBJ newQD;
+	int savedCV;
+
+	fpu_fix_start(&savedCV);
+	qd_div_s(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b);
+	fpu_fix_end(&savedCV);
+	__qNew_qdReal(newQD, c0, c1, c2, c3);
+	RETURN( newQD );
     }
     if (__isQDouble(aNumber)) {
-        double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
-        double *b = __QDoubleInstPtr(aNumber)->d_qDoubleValue;
-        double c0, c1, c2, c3;
-        OBJ newQD;
-        int savedCV;
-
-        fpu_fix_start(&savedCV);
-        qd_div_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
-        fpu_fix_end(&savedCV);
-        __qNew_qdReal(newQD, c0, c1, c2, c3);
-        RETURN( newQD );
+	double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
+	double *b = __QDoubleInstPtr(aNumber)->d_qDoubleValue;
+	double c0, c1, c2, c3;
+	OBJ newQD;
+	int savedCV;
+
+	fpu_fix_start(&savedCV);
+	qd_div_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
+	fpu_fix_end(&savedCV);
+	__qNew_qdReal(newQD, c0, c1, c2, c3);
+	RETURN( newQD );
     }
 %}.
     ^ aNumber quotientFromQDouble:self
@@ -3616,18 +3616,18 @@
 differenceFromFloat:aFloat
 %{
     if (__isFloatLike(aFloat)) {
-        double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
-        double b = __floatVal(aFloat);
-        double c0, c1, c2, c3;
-        double e;
-        OBJ newQD;
-        int savedCV;
-
-        fpu_fix_start(&savedCV);
-        s_sub_qd(&c0, &c1, &c2, &c3, b, a[0], a[1], a[2], a[3]);
-        fpu_fix_end(&savedCV);
-        __qNew_qdReal(newQD, c0, c1, c2, c3);
-        RETURN( newQD );
+	double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
+	double b = __floatVal(aFloat);
+	double c0, c1, c2, c3;
+	double e;
+	OBJ newQD;
+	int savedCV;
+
+	fpu_fix_start(&savedCV);
+	s_sub_qd(&c0, &c1, &c2, &c3, b, a[0], a[1], a[2], a[3]);
+	fpu_fix_end(&savedCV);
+	__qNew_qdReal(newQD, c0, c1, c2, c3);
+	RETURN( newQD );
     }
 %}.
     ^ super differenceFromFloat:aFloat.
@@ -3649,17 +3649,17 @@
 differenceFromQDouble:aQDouble
 %{
     if (__isQDouble(aQDouble)) {
-        double *a = __QDoubleInstPtr(aQDouble)->d_qDoubleValue;
-        double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
-        double c0, c1, c2, c3;
-        OBJ newQD;
-        int savedCV;
-
-        fpu_fix_start(&savedCV);
-        qd_sub_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
-        fpu_fix_end(&savedCV);
-        __qNew_qdReal(newQD, c0, c1, c2, c3);
-        RETURN( newQD );
+	double *a = __QDoubleInstPtr(aQDouble)->d_qDoubleValue;
+	double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
+	double c0, c1, c2, c3;
+	OBJ newQD;
+	int savedCV;
+
+	fpu_fix_start(&savedCV);
+	qd_sub_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
+	fpu_fix_end(&savedCV);
+	__qNew_qdReal(newQD, c0, c1, c2, c3);
+	RETURN( newQD );
     }
 %}.
     ^ super differenceFromQDouble:aQDouble
@@ -3740,17 +3740,17 @@
 productFromFloat:aFloat
 %{
     if (__isFloatLike(aFloat)) {
-        double a  = __floatVal(aFloat);
-        double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
-        double c0, c1, c2, c3;
-        OBJ newQD;
-        int savedCV;
-
-        fpu_fix_start(&savedCV);
-        s_mul_qd(&c0, &c1, &c2, &c3, a, b[0], b[1], b[2], b[3]);
-        fpu_fix_end(&savedCV);
-        __qNew_qdReal(newQD, c0, c1, c2, c3);
-        RETURN( newQD );
+	double a  = __floatVal(aFloat);
+	double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
+	double c0, c1, c2, c3;
+	OBJ newQD;
+	int savedCV;
+
+	fpu_fix_start(&savedCV);
+	s_mul_qd(&c0, &c1, &c2, &c3, a, b[0], b[1], b[2], b[3]);
+	fpu_fix_end(&savedCV);
+	__qNew_qdReal(newQD, c0, c1, c2, c3);
+	RETURN( newQD );
     }
 %}.
     ^ super productFromFloat:aFloat.
@@ -3767,7 +3767,7 @@
      but not here:
 
      ((1e20 asQDouble) + (1.0)) * 2.0    - 2E20  -> 2.0
-     ((1e20 asQDouble) + (1.0)) * 100.0  - 1E+22 -> 100.0 
+     ((1e20 asQDouble) + (1.0)) * 100.0  - 1E+22 -> 100.0
      ((1e20 asQDouble) + (1.0)) * 1000.0 - 1E+23 -> 8389608.0  WRONG
      ((1e20 asQDouble) + (1.0)) * 1e20   - 1E+40 ->
      ((1e40 asQDouble) + (1.0)) * 2.0    - 2E+40 ->
@@ -3801,17 +3801,17 @@
 productFromQDouble:aQDouble
 %{
     if (__isQDouble(aQDouble)) {
-        double *a = __QDoubleInstPtr(aQDouble)->d_qDoubleValue;
-        double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
-        double c0, c1, c2, c3;
-        OBJ newQD;
-        int savedCV;
-
-        fpu_fix_start(&savedCV);
-        qd_mul_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
-        fpu_fix_end(&savedCV);
-        __qNew_qdReal(newQD, c0, c1, c2, c3);
-        RETURN( newQD );
+	double *a = __QDoubleInstPtr(aQDouble)->d_qDoubleValue;
+	double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
+	double c0, c1, c2, c3;
+	OBJ newQD;
+	int savedCV;
+
+	fpu_fix_start(&savedCV);
+	qd_mul_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
+	fpu_fix_end(&savedCV);
+	__qNew_qdReal(newQD, c0, c1, c2, c3);
+	RETURN( newQD );
     }
 %}.
     ^ super productFromQDouble:aQDouble.
@@ -3837,17 +3837,17 @@
 quotientFromFloat:aFloat
 %{
     if (__isFloatLike(aFloat)) {
-        double a  = __floatVal(aFloat);
-        double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
-        double c0, c1, c2, c3;
-        OBJ newQD;
-        int savedCV;
-
-        fpu_fix_start(&savedCV);
-        s_div_qd(&c0, &c1, &c2, &c3, a, b[0], b[1], b[2], b[3]);
-        fpu_fix_end(&savedCV);
-        __qNew_qdReal(newQD, c0, c1, c2, c3);
-        RETURN( newQD );
+	double a  = __floatVal(aFloat);
+	double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
+	double c0, c1, c2, c3;
+	OBJ newQD;
+	int savedCV;
+
+	fpu_fix_start(&savedCV);
+	s_div_qd(&c0, &c1, &c2, &c3, a, b[0], b[1], b[2], b[3]);
+	fpu_fix_end(&savedCV);
+	__qNew_qdReal(newQD, c0, c1, c2, c3);
+	RETURN( newQD );
     }
 %}.
     ^ super quotientFromFloat:aFloat.
@@ -3878,17 +3878,17 @@
 quotientFromQDouble:aQDouble
 %{
     if (__isQDouble(aQDouble)) {
-        double *a = __QDoubleInstPtr(aQDouble)->d_qDoubleValue;
-        double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
-        double c0, c1, c2, c3;
-        OBJ newQD;
-        int savedCV;
-
-        fpu_fix_start(&savedCV);
-        qd_div_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
-        fpu_fix_end(&savedCV);
-        __qNew_qdReal(newQD, c0, c1, c2, c3);
-        RETURN( newQD );
+	double *a = __QDoubleInstPtr(aQDouble)->d_qDoubleValue;
+	double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
+	double c0, c1, c2, c3;
+	OBJ newQD;
+	int savedCV;
+
+	fpu_fix_start(&savedCV);
+	qd_div_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
+	fpu_fix_end(&savedCV);
+	__qNew_qdReal(newQD, c0, c1, c2, c3);
+	RETURN( newQD );
     }
 %}.
     ^ super quotientFromQDouble:aQDouble.
@@ -4028,8 +4028,8 @@
 %}.
 
     "
-     1.0 cos                 
-     (QDouble fromFloat:1.0) cos     
+     1.0 cos
+     (QDouble fromFloat:1.0) cos
     "
 !
 
@@ -4049,8 +4049,8 @@
 %}.
 
     "
-     1.0 exp     
-     (QDouble fromFloat:1.0) exp     
+     1.0 exp
+     (QDouble fromFloat:1.0) exp
     "
 !
 
@@ -4170,25 +4170,25 @@
 
 %{
     if (__isSmallInteger(n)) {
-        double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
-        double q0, q1, q2, q3;
-        OBJ newQD;
-        int savedCV;
-
-        fpu_fix_start(&savedCV);
-        qdpow(&q0, &q1, &q2, &q3, a[0], a[1], a[2], a[3], __intVal(n));
-        fpu_fix_end(&savedCV);
-        __qNew_qdReal(newQD, q0, q1, q2, q3);
-        RETURN( newQD );
+	double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
+	double q0, q1, q2, q3;
+	OBJ newQD;
+	int savedCV;
+
+	fpu_fix_start(&savedCV);
+	qdpow(&q0, &q1, &q2, &q3, a[0], a[1], a[2], a[3], __intVal(n));
+	fpu_fix_end(&savedCV);
+	__qNew_qdReal(newQD, q0, q1, q2, q3);
+	RETURN( newQD );
     }
 %}.
     ^ super raisedToInteger:n.
 
     "
-     (QDouble fromFloat:4.0) raisedToInteger:4     
-     (QDouble fromFloat:10.0) raisedToInteger:10    
-     (QDouble fromFloat:10.0000000000001) raisedToInteger:10    
-     10.0000000000001 raisedToInteger:10    
+     (QDouble fromFloat:4.0) raisedToInteger:4
+     (QDouble fromFloat:10.0) raisedToInteger:10
+     (QDouble fromFloat:10.0000000000001) raisedToInteger:10
+     10.0000000000001 raisedToInteger:10
     "
 !
 
@@ -4208,8 +4208,8 @@
 %}.
 
     "
-     1.0 sin     
-     (QDouble fromFloat:1.0) sin     
+     1.0 sin
+     (QDouble fromFloat:1.0) sin
     "
 !
 
@@ -4230,8 +4230,8 @@
 %}.
 
     "
-     (QDouble fromFloat:4.0) sqrt     
-     (QDouble fromFloat:2.0) sqrt     
+     (QDouble fromFloat:4.0) sqrt
+     (QDouble fromFloat:2.0) sqrt
      (QDouble fromFloat:1e20) sqrt
     "
 !
@@ -4277,8 +4277,8 @@
 %}.
 
     "
-     1.0 tan                 
-     (QDouble fromFloat:1.0) tan     
+     1.0 tan
+     (QDouble fromFloat:1.0) tan
     "
 ! !
 
@@ -5000,16 +5000,16 @@
     x0 = ceil(a[0]);
 
     if (x0 == a[0]) {
-        x1 = ceil(a[1]);
-        if (x1 == a[1]) {
-            x2 = ceil(a[2]);
-            if (x2 == a[2]) {
-                x3 = ceil(a[3]);
-            }
-        }
-        fpu_fix_start(&savedCV);
-        m_renorm4(x0, x1, x2, x3);
-        fpu_fix_end(&savedCV);
+	x1 = ceil(a[1]);
+	if (x1 == a[1]) {
+	    x2 = ceil(a[2]);
+	    if (x2 == a[2]) {
+		x3 = ceil(a[3]);
+	    }
+	}
+	fpu_fix_start(&savedCV);
+	m_renorm4(x0, x1, x2, x3);
+	fpu_fix_end(&savedCV);
     }
     __qNew_qdReal(newQD, x0, x1, x2, x3);
     RETURN( newQD );
@@ -5067,16 +5067,16 @@
     x0 =floor(a[0]);
 
     if (x0 == a[0]) {
-        x1 = floor(a[1]);
-        if (x1 == a[1]) {
-            x2 = floor(a[2]);
-            if (x2 == a[2]) {
-                x3 = floor(a[3]);
-            }
-        }
-        fpu_fix_start(&savedCV);
-        m_renorm4(x0, x1, x2, x3);
-        fpu_fix_end(&savedCV);
+	x1 = floor(a[1]);
+	if (x1 == a[1]) {
+	    x2 = floor(a[2]);
+	    if (x2 == a[2]) {
+		x3 = floor(a[3]);
+	    }
+	}
+	fpu_fix_start(&savedCV);
+	m_renorm4(x0, x1, x2, x3);
+	fpu_fix_end(&savedCV);
     }
     __qNew_qdReal(newQD, x0, x1, x2, x3);
     RETURN( newQD );
@@ -5180,4 +5180,3 @@
 version_CVS
     ^ '$Header$'
 ! !
-