Lines Matching +full:0 +full:a
16 * of this code was written as part of a project to build a fixed-point vector
42 #define LIT64( a ) a##LL argument
71 bits64 extractFloat64Frac(float64 a);
72 flag extractFloat64Sign(float64 a);
73 int16 extractFloat64Exp(float64 a);
74 int16 extractFloat32Exp(float32 a);
75 flag extractFloat32Sign(float32 a);
76 bits32 extractFloat32Frac(float32 a);
78 void shift64RightJamming(bits64 a, int16 count, bits64 * zPtr);
80 void shift32RightJamming(bits32 a, int16 count, bits32 * zPtr);
81 float64 float64_sub(float64 a, float64 b);
82 float32 float32_sub(float32 a, float32 b);
83 float32 float32_add(float32 a, float32 b);
84 float64 float64_add(float64 a, float64 b);
85 float64 float64_div(float64 a, float64 b);
86 float32 float32_div(float32 a, float32 b);
87 float32 float32_mul(float32 a, float32 b);
88 float64 float64_mul(float64 a, float64 b);
89 float32 float64_to_float32(float64 a);
94 void mul64To128(bits64 a, bits64 b, bits64 * z0Ptr, bits64 * z1Ptr);
96 static int8 countLeadingZeros32(bits32 a);
97 static int8 countLeadingZeros64(bits64 a);
100 static float64 subFloat64Sigs(float64 a, float64 b, flag zSign);
101 static float64 addFloat64Sigs(float64 a, float64 b, flag zSign);
106 static float32 subFloat32Sigs(float32 a, float32 b, flag zSign);
107 static float32 addFloat32Sigs(float32 a, float32 b, flag zSign);
114 bits64 extractFloat64Frac(float64 a) in extractFloat64Frac() argument
116 return a & LIT64(0x000FFFFFFFFFFFFF); in extractFloat64Frac()
119 flag extractFloat64Sign(float64 a) in extractFloat64Sign() argument
121 return a >> 63; in extractFloat64Sign()
124 int16 extractFloat64Exp(float64 a) in extractFloat64Exp() argument
126 return (a >> 52) & 0x7FF; in extractFloat64Exp()
129 int16 extractFloat32Exp(float32 a) in extractFloat32Exp() argument
131 return (a >> 23) & 0xFF; in extractFloat32Exp()
134 flag extractFloat32Sign(float32 a) in extractFloat32Sign() argument
136 return a >> 31; in extractFloat32Sign()
139 bits32 extractFloat32Frac(float32 a) in extractFloat32Frac() argument
141 return a & 0x007FFFFF; in extractFloat32Frac()
149 void shift64RightJamming(bits64 a, int16 count, bits64 * zPtr) in shift64RightJamming() argument
153 if (count == 0) { in shift64RightJamming()
154 z = a; in shift64RightJamming()
156 z = (a >> count) | ((a << ((-count) & 63)) != 0); in shift64RightJamming()
158 z = (a != 0); in shift64RightJamming()
163 static int8 countLeadingZeros32(bits32 a) in countLeadingZeros32() argument
174 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, in countLeadingZeros32()
175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, in countLeadingZeros32()
176 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, in countLeadingZeros32()
177 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, in countLeadingZeros32()
178 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, in countLeadingZeros32()
179 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, in countLeadingZeros32()
180 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, in countLeadingZeros32()
181 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 in countLeadingZeros32()
185 shiftCount = 0; in countLeadingZeros32()
186 if (a < 0x10000) { in countLeadingZeros32()
188 a <<= 16; in countLeadingZeros32()
190 if (a < 0x1000000) { in countLeadingZeros32()
192 a <<= 8; in countLeadingZeros32()
194 shiftCount += countLeadingZerosHigh[a >> 24]; in countLeadingZeros32()
199 static int8 countLeadingZeros64(bits64 a) in countLeadingZeros64() argument
203 shiftCount = 0; in countLeadingZeros64()
204 if (a < ((bits64) 1) << 32) { in countLeadingZeros64()
207 a >>= 32; in countLeadingZeros64()
209 shiftCount += countLeadingZeros32(a); in countLeadingZeros64()
224 static float64 subFloat64Sigs(float64 a, float64 b, flag zSign) in subFloat64Sigs() argument
230 aSig = extractFloat64Frac(a); in subFloat64Sigs()
231 aExp = extractFloat64Exp(a); in subFloat64Sigs()
237 if (0 < expDiff) in subFloat64Sigs()
239 if (expDiff < 0) in subFloat64Sigs()
241 if (aExp == 0) { in subFloat64Sigs()
249 return packFloat64(float_rounding_mode() == FPSCR_RM_ZERO, 0, 0); in subFloat64Sigs()
251 if (bExp == 0x7FF) { in subFloat64Sigs()
252 return packFloat64(zSign ^ 1, 0x7FF, 0); in subFloat64Sigs()
254 if (aExp == 0) { in subFloat64Sigs()
257 aSig |= LIT64(0x4000000000000000); in subFloat64Sigs()
260 bSig |= LIT64(0x4000000000000000); in subFloat64Sigs()
267 if (aExp == 0x7FF) { in subFloat64Sigs()
268 return a; in subFloat64Sigs()
270 if (bExp == 0) { in subFloat64Sigs()
273 bSig |= LIT64(0x4000000000000000); in subFloat64Sigs()
276 aSig |= LIT64(0x4000000000000000); in subFloat64Sigs()
285 static float64 addFloat64Sigs(float64 a, float64 b, flag zSign) in addFloat64Sigs() argument
291 aSig = extractFloat64Frac(a); in addFloat64Sigs()
292 aExp = extractFloat64Exp(a); in addFloat64Sigs()
298 if (0 < expDiff) { in addFloat64Sigs()
299 if (aExp == 0x7FF) { in addFloat64Sigs()
300 return a; in addFloat64Sigs()
302 if (bExp == 0) { in addFloat64Sigs()
305 bSig |= LIT64(0x2000000000000000); in addFloat64Sigs()
309 } else if (expDiff < 0) { in addFloat64Sigs()
310 if (bExp == 0x7FF) { in addFloat64Sigs()
311 return packFloat64(zSign, 0x7FF, 0); in addFloat64Sigs()
313 if (aExp == 0) { in addFloat64Sigs()
316 aSig |= LIT64(0x2000000000000000); in addFloat64Sigs()
321 if (aExp == 0x7FF) { in addFloat64Sigs()
322 return a; in addFloat64Sigs()
324 if (aExp == 0) in addFloat64Sigs()
325 return packFloat64(zSign, 0, (aSig + bSig) >> 9); in addFloat64Sigs()
326 zSig = LIT64(0x4000000000000000) + aSig + bSig; in addFloat64Sigs()
330 aSig |= LIT64(0x2000000000000000); in addFloat64Sigs()
333 if ((sbits64) zSig < 0) { in addFloat64Sigs()
347 void shift32RightJamming(bits32 a, int16 count, bits32 * zPtr) in shift32RightJamming() argument
350 if (count == 0) { in shift32RightJamming()
351 z = a; in shift32RightJamming()
353 z = (a >> count) | ((a << ((-count) & 31)) != 0); in shift32RightJamming()
355 z = (a != 0); in shift32RightJamming()
368 roundIncrement = 0x40; in roundAndPackFloat32()
370 roundIncrement = 0; in roundAndPackFloat32()
372 roundBits = zSig & 0x7F; in roundAndPackFloat32()
373 if (0xFD <= (bits16) zExp) { in roundAndPackFloat32()
374 if ((0xFD < zExp) in roundAndPackFloat32()
375 || ((zExp == 0xFD) in roundAndPackFloat32()
376 && ((sbits32) (zSig + roundIncrement) < 0)) in roundAndPackFloat32()
379 return packFloat32(zSign, 0xFF, in roundAndPackFloat32()
380 0) - (roundIncrement == 0); in roundAndPackFloat32()
382 if (zExp < 0) { in roundAndPackFloat32()
384 || (zSig + roundIncrement < 0x80000000); in roundAndPackFloat32()
386 zExp = 0; in roundAndPackFloat32()
387 roundBits = zSig & 0x7F; in roundAndPackFloat32()
395 zSig &= ~(((roundBits ^ 0x40) == 0) & roundNearestEven); in roundAndPackFloat32()
396 if (zSig == 0) in roundAndPackFloat32()
397 zExp = 0; in roundAndPackFloat32()
419 roundIncrement = 0x200; in roundAndPackFloat64()
421 roundIncrement = 0; in roundAndPackFloat64()
423 roundBits = zSig & 0x3FF; in roundAndPackFloat64()
424 if (0x7FD <= (bits16) zExp) { in roundAndPackFloat64()
425 if ((0x7FD < zExp) in roundAndPackFloat64()
426 || ((zExp == 0x7FD) in roundAndPackFloat64()
427 && ((sbits64) (zSig + roundIncrement) < 0)) in roundAndPackFloat64()
430 return packFloat64(zSign, 0x7FF, in roundAndPackFloat64()
431 0) - (roundIncrement == 0); in roundAndPackFloat64()
433 if (zExp < 0) { in roundAndPackFloat64()
436 LIT64(0x8000000000000000)); in roundAndPackFloat64()
438 zExp = 0; in roundAndPackFloat64()
439 roundBits = zSig & 0x3FF; in roundAndPackFloat64()
447 zSig &= ~(((roundBits ^ 0x200) == 0) & roundNearestEven); in roundAndPackFloat64()
448 if (zSig == 0) in roundAndPackFloat64()
449 zExp = 0; in roundAndPackFloat64()
454 static float32 subFloat32Sigs(float32 a, float32 b, flag zSign) in subFloat32Sigs() argument
460 aSig = extractFloat32Frac(a); in subFloat32Sigs()
461 aExp = extractFloat32Exp(a); in subFloat32Sigs()
467 if (0 < expDiff) in subFloat32Sigs()
469 if (expDiff < 0) in subFloat32Sigs()
471 if (aExp == 0) { in subFloat32Sigs()
479 return packFloat32(float_rounding_mode() == FPSCR_RM_ZERO, 0, 0); in subFloat32Sigs()
481 if (bExp == 0xFF) { in subFloat32Sigs()
482 return packFloat32(zSign ^ 1, 0xFF, 0); in subFloat32Sigs()
484 if (aExp == 0) { in subFloat32Sigs()
487 aSig |= 0x40000000; in subFloat32Sigs()
490 bSig |= 0x40000000; in subFloat32Sigs()
497 if (aExp == 0xFF) { in subFloat32Sigs()
498 return a; in subFloat32Sigs()
500 if (bExp == 0) { in subFloat32Sigs()
503 bSig |= 0x40000000; in subFloat32Sigs()
506 aSig |= 0x40000000; in subFloat32Sigs()
516 static float32 addFloat32Sigs(float32 a, float32 b, flag zSign) in addFloat32Sigs() argument
522 aSig = extractFloat32Frac(a); in addFloat32Sigs()
523 aExp = extractFloat32Exp(a); in addFloat32Sigs()
529 if (0 < expDiff) { in addFloat32Sigs()
530 if (aExp == 0xFF) { in addFloat32Sigs()
531 return a; in addFloat32Sigs()
533 if (bExp == 0) { in addFloat32Sigs()
536 bSig |= 0x20000000; in addFloat32Sigs()
540 } else if (expDiff < 0) { in addFloat32Sigs()
541 if (bExp == 0xFF) { in addFloat32Sigs()
542 return packFloat32(zSign, 0xFF, 0); in addFloat32Sigs()
544 if (aExp == 0) { in addFloat32Sigs()
547 aSig |= 0x20000000; in addFloat32Sigs()
552 if (aExp == 0xFF) { in addFloat32Sigs()
553 return a; in addFloat32Sigs()
555 if (aExp == 0) in addFloat32Sigs()
556 return packFloat32(zSign, 0, (aSig + bSig) >> 6); in addFloat32Sigs()
557 zSig = 0x40000000 + aSig + bSig; in addFloat32Sigs()
561 aSig |= 0x20000000; in addFloat32Sigs()
564 if ((sbits32) zSig < 0) { in addFloat32Sigs()
573 float64 float64_sub(float64 a, float64 b) in float64_sub() argument
577 aSign = extractFloat64Sign(a); in float64_sub()
580 return subFloat64Sigs(a, b, aSign); in float64_sub()
582 return addFloat64Sigs(a, b, aSign); in float64_sub()
587 float32 float32_sub(float32 a, float32 b) in float32_sub() argument
591 aSign = extractFloat32Sign(a); in float32_sub()
594 return subFloat32Sigs(a, b, aSign); in float32_sub()
596 return addFloat32Sigs(a, b, aSign); in float32_sub()
601 float32 float32_add(float32 a, float32 b) in float32_add() argument
605 aSign = extractFloat32Sign(a); in float32_add()
608 return addFloat32Sigs(a, b, aSign); in float32_add()
610 return subFloat32Sigs(a, b, aSign); in float32_add()
615 float64 float64_add(float64 a, float64 b) in float64_add() argument
619 aSign = extractFloat64Sign(a); in float64_add()
622 return addFloat64Sigs(a, b, aSign); in float64_add()
624 return subFloat64Sigs(a, b, aSign); in float64_add()
662 return LIT64(0xFFFFFFFFFFFFFFFF); in estimateDiv128To64()
667 z = (b0 << 32 <= a0) ? LIT64(0xFFFFFFFF00000000) : tmp << 32; in estimateDiv128To64()
670 while (((sbits64) rem0) < 0) { in estimateDiv128To64()
671 z -= LIT64(0x100000000); in estimateDiv128To64()
678 z |= (b0 << 32 <= rem0) ? 0xFFFFFFFF : tmp; in estimateDiv128To64()
682 void mul64To128(bits64 a, bits64 b, bits64 * z0Ptr, bits64 * z1Ptr) in mul64To128() argument
687 aLow = a; in mul64To128()
688 aHigh = a >> 32; in mul64To128()
716 float64 float64_div(float64 a, float64 b) in float64_div() argument
724 aSig = extractFloat64Frac(a); in float64_div()
725 aExp = extractFloat64Exp(a); in float64_div()
726 aSign = extractFloat64Sign(a); in float64_div()
731 if (aExp == 0x7FF) { in float64_div()
732 if (bExp == 0x7FF) { in float64_div()
734 return packFloat64(zSign, 0x7FF, 0); in float64_div()
736 if (bExp == 0x7FF) { in float64_div()
737 return packFloat64(zSign, 0, 0); in float64_div()
739 if (bExp == 0) { in float64_div()
740 if (bSig == 0) { in float64_div()
741 if ((aExp | aSig) == 0) { in float64_div()
744 return packFloat64(zSign, 0x7FF, 0); in float64_div()
748 if (aExp == 0) { in float64_div()
749 if (aSig == 0) in float64_div()
750 return packFloat64(zSign, 0, 0); in float64_div()
753 zExp = aExp - bExp + 0x3FD; in float64_div()
754 aSig = (aSig | LIT64(0x0010000000000000)) << 10; in float64_div()
755 bSig = (bSig | LIT64(0x0010000000000000)) << 11; in float64_div()
760 zSig = estimateDiv128To64(aSig, 0, bSig); in float64_div()
761 if ((zSig & 0x1FF) <= 2) { in float64_div()
763 sub128(aSig, 0, term0, term1, &rem0, &rem1); in float64_div()
764 while ((sbits64) rem0 < 0) { in float64_div()
766 add128(rem0, rem1, 0, bSig, &rem0, &rem1); in float64_div()
768 zSig |= (rem1 != 0); in float64_div()
774 float32 float32_div(float32 a, float32 b) in float32_div() argument
781 aSig = extractFloat32Frac(a); in float32_div()
782 aExp = extractFloat32Exp(a); in float32_div()
783 aSign = extractFloat32Sign(a); in float32_div()
788 if (aExp == 0xFF) { in float32_div()
789 if (bExp == 0xFF) { in float32_div()
791 return packFloat32(zSign, 0xFF, 0); in float32_div()
793 if (bExp == 0xFF) { in float32_div()
794 return packFloat32(zSign, 0, 0); in float32_div()
796 if (bExp == 0) { in float32_div()
797 if (bSig == 0) { in float32_div()
798 return packFloat32(zSign, 0xFF, 0); in float32_div()
802 if (aExp == 0) { in float32_div()
803 if (aSig == 0) in float32_div()
804 return packFloat32(zSign, 0, 0); in float32_div()
807 zExp = aExp - bExp + 0x7D; in float32_div()
808 aSig = (aSig | 0x00800000) << 7; in float32_div()
809 bSig = (bSig | 0x00800000) << 8; in float32_div()
817 if ((zSig & 0x3F) == 0) { in float32_div()
824 float32 float32_mul(float32 a, float32 b) in float32_mul() argument
832 aSig = extractFloat32Frac(a); in float32_mul()
833 aExp = extractFloat32Exp(a); in float32_mul()
834 aSign = extractFloat32Sign(a); in float32_mul()
839 if (aExp == 0) { in float32_mul()
840 if (aSig == 0) in float32_mul()
841 return packFloat32(zSign, 0, 0); in float32_mul()
844 if (bExp == 0) { in float32_mul()
845 if (bSig == 0) in float32_mul()
846 return packFloat32(zSign, 0, 0); in float32_mul()
849 if ((bExp == 0xff && bSig == 0) || (aExp == 0xff && aSig == 0)) in float32_mul()
850 return roundAndPackFloat32(zSign, 0xff, 0); in float32_mul()
852 zExp = aExp + bExp - 0x7F; in float32_mul()
853 aSig = (aSig | 0x00800000) << 7; in float32_mul()
854 bSig = (bSig | 0x00800000) << 8; in float32_mul()
857 if (0 <= (signed int)(zSig << 1)) { in float32_mul()
865 float64 float64_mul(float64 a, float64 b) in float64_mul() argument
871 aSig = extractFloat64Frac(a); in float64_mul()
872 aExp = extractFloat64Exp(a); in float64_mul()
873 aSign = extractFloat64Sign(a); in float64_mul()
879 if (aExp == 0) { in float64_mul()
880 if (aSig == 0) in float64_mul()
881 return packFloat64(zSign, 0, 0); in float64_mul()
884 if (bExp == 0) { in float64_mul()
885 if (bSig == 0) in float64_mul()
886 return packFloat64(zSign, 0, 0); in float64_mul()
889 if ((aExp == 0x7ff && aSig == 0) || (bExp == 0x7ff && bSig == 0)) in float64_mul()
890 return roundAndPackFloat64(zSign, 0x7ff, 0); in float64_mul()
892 zExp = aExp + bExp - 0x3FF; in float64_mul()
893 aSig = (aSig | 0x0010000000000000LL) << 10; in float64_mul()
894 bSig = (bSig | 0x0010000000000000LL) << 11; in float64_mul()
896 zSig0 |= (zSig1 != 0); in float64_mul()
897 if (0 <= (signed long long int)(zSig0 << 1)) { in float64_mul()
907 * `a' to the single-precision floating-point format. The conversion is
912 float32 float64_to_float32(float64 a) in float64_to_float32() argument
919 aSig = extractFloat64Frac( a ); in float64_to_float32()
920 aExp = extractFloat64Exp( a ); in float64_to_float32()
921 aSign = extractFloat64Sign( a ); in float64_to_float32()
926 zSig |= 0x40000000; in float64_to_float32()
927 aExp -= 0x381; in float64_to_float32()