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:
parent
4ef36fb822
commit
78c53d7e61
1 changed files with 1 additions and 11 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue