SCHEME_OBJECT integer = (ARG_REF (1));
long control = (arg_index_integer (2, 4));
if (FIXNUM_P (integer))
- {
- long X = (FIXNUM_TO_LONG (integer));
- double Y = ((double) X);
-
- if (((long) Y) == X)
- PRIMITIVE_RETURN (FIXNUM_TO_FLONUM (integer));
- if ((control & 2) != 0)
- error_bad_range_arg (1);
- PRIMITIVE_RETURN (SHARP_F);
- }
- if (bignum_fits_in_word_p
- (integer,
- (((control & 1) != 0) ? DBL_MANT_DIG : DBL_MAX_EXP),
- 0))
+ PRIMITIVE_RETURN (FIXNUM_TO_FLONUM (integer));
+ if (((control & 1) != 0)
+ ? (LOSSLESS_BIGNUM_TO_DOUBLE_P (integer))
+ : (BIGNUM_TO_DOUBLE_P (integer)))
PRIMITIVE_RETURN (BIGNUM_TO_FLONUM (integer));
if ((control & 2) != 0)
error_bad_range_arg (1);
(bignum_fits_in_word_p ((bignum), ((sizeof (unsigned long)) * CHAR_BIT), 0))
#define BIGNUM_TO_DOUBLE_P(bignum) \
- (bignum_fits_in_word_p ((bignum), DBL_MAX_EXP, 0))
+ (bignum_fits_in_word_p ((bignum), (DBL_MAX_EXP + 1), 1))
#define LOSSLESS_BIGNUM_TO_DOUBLE_P(bignum) \
- (bignum_fits_in_word_p ((bignum), DBL_MANT_DIG, 0))
+ (bignum_fits_in_word_p ((bignum), (DBL_MANT_DIG + 1), 1))
/* Flonum Operations */