2539 ^ $Q |
2539 ^ $Q |
2540 |
2540 |
2541 "Created: / 10-06-2019 / 21:28:04 / Claus Gittinger" |
2541 "Created: / 10-06-2019 / 21:28:04 / Claus Gittinger" |
2542 ! |
2542 ! |
2543 |
2543 |
|
2544 numBitsInExponent |
|
2545 "answer the number of bits in the exponent |
|
2546 the hidden bit is not counted here: |
|
2547 |
|
2548 This is an 128bit quadfloat, |
|
2549 where 15 bits are available in the exponent: |
|
2550 seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm... |
|
2551 " |
|
2552 |
|
2553 ^ 15 |
|
2554 |
|
2555 " |
|
2556 1.0 class numBitsInExponent -> 11 |
|
2557 1.0 asShortFloat class numBitsInExponent -> 8 |
|
2558 1.0 asLongFloat class numBitsInExponent -> 15 |
|
2559 1.0 asQuadFloat class numBitsInExponent -> 15 |
|
2560 " |
|
2561 |
|
2562 "Created: / 11-06-2019 / 00:14:55 / Claus Gittinger" |
|
2563 ! |
|
2564 |
2544 numBitsInMantissa |
2565 numBitsInMantissa |
2545 "answer the number of bits in the mantissa |
2566 "answer the number of bits in the mantissa |
2546 the hidden bit is not counted here: |
2567 the hidden bit is not counted here: |
2547 |
2568 |
2548 This is an 128bit quadfloat, |
2569 This is an 128bit quadfloat, |
2593 ^ ZeroDivide raiseRequestWith:thisContext. |
2614 ^ ZeroDivide raiseRequestWith:thisContext. |
2594 ]. |
2615 ]. |
2595 ^ aNumber quotientFromQuadFloat:self |
2616 ^ aNumber quotientFromQuadFloat:self |
2596 ! |
2617 ! |
2597 |
2618 |
|
2619 negated |
|
2620 "return the receiver negated" |
|
2621 |
|
2622 %{ /* NOCONTEXT */ |
|
2623 #ifdef SUPPORT_QUADFLOAT |
|
2624 OBJ newFloat; |
|
2625 float128_t result, myVal; |
|
2626 |
|
2627 myVal = __quadFloatVal(self); |
|
2628 f128M_negate( &myVal, &result ); |
|
2629 __qMKQFLOAT(newFloat, result); |
|
2630 RETURN ( newFloat ); |
|
2631 #endif |
|
2632 %}. |
|
2633 ! |
|
2634 |
2598 rem: aNumber |
2635 rem: aNumber |
2599 "return the floating point remainder of the receiver and the argument, aNumber" |
2636 "return the floating point remainder of the receiver and the argument, aNumber" |
2600 |
2637 |
2601 aNumber isZero ifTrue:[ |
2638 aNumber isZero ifTrue:[ |
2602 " |
2639 " |
2603 No, you shalt not divide by zero |
2640 No, you shalt not divide by zero |
2604 " |
2641 " |
2605 ^ ZeroDivide raiseRequestWith:thisContext. |
2642 ^ ZeroDivide raiseRequestWith:thisContext. |
2606 ]. |
2643 ]. |
2607 ^ aNumber remainderFromLongFloat:self |
2644 ^ aNumber remainderFromLongFloat:self |
2608 ! |
|
2609 |
|
2610 negated |
|
2611 "return the receiver negated" |
|
2612 |
|
2613 %{ /* NOCONTEXT */ |
|
2614 #ifdef SUPPORT_QUADFLOAT |
|
2615 OBJ newFloat; |
|
2616 float128_t result, myVal; |
|
2617 |
|
2618 myVal = __quadFloatVal(self); |
|
2619 f128M_negate( &myVal, &result ); |
|
2620 __qMKQFLOAT(newFloat, result); |
|
2621 RETURN ( newFloat ); |
|
2622 #endif |
|
2623 %}. |
|
2624 ! ! |
2645 ! ! |
2625 |
2646 |
2626 !QuadFloat methodsFor:'coercing & converting'! |
2647 !QuadFloat methodsFor:'coercing & converting'! |
2627 |
2648 |
2628 generality |
2649 generality |
2803 |
2824 |
2804 errorUnsupported |
2825 errorUnsupported |
2805 self class errorUnsupported |
2826 self class errorUnsupported |
2806 |
2827 |
2807 "Modified: / 07-06-2019 / 02:44:51 / Claus Gittinger" |
2828 "Modified: / 07-06-2019 / 02:44:51 / Claus Gittinger" |
|
2829 ! ! |
|
2830 |
|
2831 !QuadFloat methodsFor:'printing'! |
|
2832 |
|
2833 printOn:aStream |
|
2834 |mantissa exponent| |
|
2835 |
|
2836 mantissa := self mantissa. |
|
2837 exponent := self exponent. |
|
2838 |
|
2839 self exponent == 0 ifTrue:[ |
|
2840 mantissa printOn:aStream. |
|
2841 aStream nextPutAll:'.0'. |
|
2842 ^ self |
|
2843 ]. |
|
2844 mantissa == 0 ifTrue:[ |
|
2845 "/ a zero mantissa is impossible - except for zero and a few others |
|
2846 exponent == 0 ifTrue:[ aStream nextPutAll:'0.0'. ^ self]. |
|
2847 self == NaN ifTrue:[ aStream nextPutAll:'NAN'. ^ self ]. |
|
2848 self == NegativeInfinity ifTrue:[ aStream nextPutAll:'-INF'. ^ self]. |
|
2849 self == PositiveInfinity ifTrue:[ aStream nextPutAll:'INF'. ^ self]. |
|
2850 |
|
2851 self error:'invalid largeFloat' mayProceed:true. |
|
2852 aStream nextPutAll:'Invalid'. ^ self. |
|
2853 ]. |
|
2854 |
|
2855 exponent >= 0 ifTrue:[ |
|
2856 (mantissa bitShift:exponent) printOn:aStream. |
|
2857 aStream nextPutAll:'.0'. |
|
2858 ^ self |
|
2859 ]. |
|
2860 ((mantissa / (1 bitShift:exponent negated)) asFixedPoint:6) printOn:aStream. |
|
2861 |
|
2862 "Created: / 11-06-2019 / 00:13:00 / Claus Gittinger" |
2808 ! ! |
2863 ! ! |
2809 |
2864 |
2810 !QuadFloat methodsFor:'queries'! |
2865 !QuadFloat methodsFor:'queries'! |
2811 |
2866 |
2812 isFinite |
2867 isFinite |