Changeset 31348 in project
 Timestamp:
 09/09/14 13:49:41 (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

release/4/numbers/trunk/numbersc.c
r31347 r31348 2642 2642 } 2643 2643 2644 #define DTB_WRITE_DIGIT(factor) \2645 { \2646 significand *= (factor); \2647 digit = ((C_word)significand); \2648 (*scan) = digit; \2649 significand = ((double)digit); \2650 }2651 2652 2644 static void 2653 2645 flo_to_int_2(C_word c, C_word self, C_word result) … … 2655 2647 C_word digit, k = C_block_item(self, 1), 2656 2648 exponent = C_unfix(C_block_item(self, 2)), 2649 odd_bits = exponent % C_BIGNUM_DIGIT_LENGTH, 2657 2650 *start = C_bignum_digits(result), 2658 2651 *scan = start + C_bignum_size(result); 2652 /* It's always true that 0.5 <= s < 1 */ 2659 2653 double significand = C_flonum_magnitude(C_block_item(self, 3)); 2660 int odd_bits = exponent % C_BIGNUM_DIGIT_LENGTH; 2661 2662 if (odd_bits > 0) 2663 DTB_WRITE_DIGIT (1L << odd_bits); 2664 2665 while (start < scan && significand > 0) 2666 DTB_WRITE_DIGIT(BIGNUM_RADIX); 2667 2668 /* Finish up by clearing any remaining, higher, digits */ 2654 2655 if (odd_bits > 0) { /* Handle most significant digit first */ 2656 significand *= (C_word)1 << odd_bits; 2657 digit = (C_word)significand; 2658 (*scan) = digit; 2659 significand = (double)digit; 2660 } 2661 2662 while (start < scan && significand > 0) { 2663 significand *= (C_word)1 << C_BIGNUM_DIGIT_LENGTH; 2664 digit = (C_word)significand; 2665 (*scan) = digit; 2666 significand = (double)digit; 2667 } 2668 2669 /* Finish up by clearing any remaining, lower, digits */ 2669 2670 while (start < scan) 2670 2671 (*scan) = 0; … … 2673 2674 C_kontinue(k, C_bignum_normalize(result)); 2674 2675 } 2675 #undef DTB_WRITE_DIGIT
Note: See TracChangeset
for help on using the changeset viewer.