guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scm_integer_p and scm_num2int mismatch


From: Marius Vollmer
Subject: Re: scm_integer_p and scm_num2int mismatch
Date: 07 Oct 2001 23:49:41 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.102

Jan Nieuwenhuizen <address@hidden> writes:

> Is this intentional, ie, should
> 
>   if (scm_integer_p (s) == SCM_BOOL_T)
>     printf ("%d\n", gh_num2int (s));
> 
> be changed to:
> 
>   if (scm_integer_p (s) == SCM_BOOL_T)
>     {
>       if (scm_exact_p (s) == SCM_BOOL_F)
>         printf ("%d\n", gh_num2int (s));
>       else
>         printf ("%d\n", gh_num2int (scm_inexact_to_exact (s)));
>     }

No, it should be changed to

    if (SCM_NFALSEP (scm_integer_p (s)))
      {
        scm_display (s, scm_current_output_port ());
        scm_newline (scm_current_output_port ());
      }

But more seriously, you need to insert a call to scm_inexact_to_exact
when you want to deal with reals as well as integers.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]