Changeset 31348 in project


Ignore:
Timestamp:
09/09/14 13:49:41 (5 years ago)
Author:
sjamaan
Message:

numbers: Remove somewhat ugly and pointless macro by duplicating the code inline instead

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/numbers/trunk/numbers-c.c

    r31347 r31348  
    26422642}
    26432643
    2644 #define DTB_WRITE_DIGIT(factor)                                         \
    2645 {                                                                       \
    2646   significand *= (factor);                                              \
    2647   digit = ((C_word)significand);                                        \
    2648   (*--scan) = digit;                                                    \
    2649   significand -= ((double)digit);                                       \
    2650 }
    2651 
    26522644static void
    26532645flo_to_int_2(C_word c, C_word self, C_word result)
     
    26552647  C_word digit, k = C_block_item(self, 1),
    26562648         exponent = C_unfix(C_block_item(self, 2)),
     2649         odd_bits = exponent % C_BIGNUM_DIGIT_LENGTH,
    26572650         *start = C_bignum_digits(result),
    26582651         *scan = start + C_bignum_size(result);
     2652  /* It's always true that 0.5 <= s < 1 */
    26592653  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 */
    26692670  while (start < scan)
    26702671    (*--scan) = 0;
     
    26732674  C_kontinue(k, C_bignum_normalize(result));
    26742675}
    2675 #undef DTB_WRITE_DIGIT
Note: See TracChangeset for help on using the changeset viewer.