[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: scm_num2float() ?
From: |
Michael Livshin |
Subject: |
Re: scm_num2float() ? |
Date: |
01 Sep 2001 18:15:27 +0300 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Copyleft) |
Martin Baulig <address@hidden> writes:
> Michael Livshin <address@hidden> writes:
>
> > Martin Baulig <address@hidden> writes:
> >
> > > what do you think about adding something like
> > >
> > > float scm_num2float (SCM a, const char *why);
> > >
> > > either as function or as macro which does the typechecking
> > > to make sure that the value fits into a C float ?
> >
> > why would a number _not_ fit in a C float?
>
> For instance 1.0e40 won't fit into a C float - since MAX_FLT is normally
> about 3.8e38.
ah, right. sorry.
> I was thinking of something like the following:
>
> ====
> #define SCM_VALIDATE_FLOAT_COPY(pos,z,cvar) \
> do { \
> double x; \
> SCM_ASSERT (SCM_INUMP (z) || SCM_BIGP (z) || SCM_REALP (z), z, pos,
> FUNC_NAME); \
> x = scm_num2dbl (z, FUNC_NAME); \
> SCM_ASSERT_RANGE (pos, z, (- G_MAXFLOAT <= x) && (x <= G_MAXFLOAT)); \
> cvar = (float) x; \
> } while (0)
> ====
I think if we do this, then we should have `scm_num2float' too.
I wonder if I should add this in the stable branch?
--
There is no such thing as a "great rock critic" any more than there are
"great parasites". -- Mike Dickson, in rec.music.progressive
- scm_num2float() ?, Martin Baulig, 2001/09/01
- Re: scm_num2float() ?, Michael Livshin, 2001/09/01
- Re: scm_num2float() ?, Martin Baulig, 2001/09/01
- Re: scm_num2float() ?, Dirk Herrmann, 2001/09/03
- Re: scm_num2float() ?, Martin Baulig, 2001/09/03
- Re: scm_num2float() ?, Michael Livshin, 2001/09/03
- Re: scm_num2float() ?, Martin Baulig, 2001/09/04
- Re: scm_num2float() ?, Dirk Herrmann, 2001/09/04
- Re: scm_num2float() ?, Michael Livshin, 2001/09/04