1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-12 23:00:22 +02:00

* num2float.i.c (NUM2FLOAT): handle GMP bignums.

This commit is contained in:
Rob Browning 2003-04-04 21:49:03 +00:00
parent 4ef36fb822
commit 78c53d7e61

View file

@ -7,16 +7,7 @@ NUM2FLOAT (SCM num, unsigned long int pos, const char *s_caller)
return SCM_INUM (num); return SCM_INUM (num);
else if (SCM_BIGP (num)) else if (SCM_BIGP (num))
{ /* bignum */ { /* bignum */
FTYPE res = mpz_get_d (SCM_I_BIG_MPZ (num));
FTYPE res = 0.0;
size_t l;
for (l = SCM_NUMDIGS (num); l--;)
res = SCM_BIGRAD * res + SCM_BDIGITS (num)[l];
if (SCM_BIGSIGN (num))
res = -res;
if (isfinite (res)) if (isfinite (res))
return res; return res;
else else
@ -32,7 +23,6 @@ SCM
FLOAT2NUM (FTYPE n) FLOAT2NUM (FTYPE n)
{ {
SCM z = scm_double_cell (scm_tc16_real, 0, 0, 0); SCM z = scm_double_cell (scm_tc16_real, 0, 0, 0);
SCM_REAL_VALUE (z) = n; SCM_REAL_VALUE (z) = n;
return z; return z;
} }