[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: scm_num2float() ?
From: |
Martin Baulig |
Subject: |
Re: scm_num2float() ? |
Date: |
01 Sep 2001 16:36:45 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
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.
> should `scm_num2float' check whether there will be a loss of precision
> compared with double? I'm not sure such a check is very useful (and
> I'm not sure its result would be predictable, either).
No, this shouldn't be necessary.
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)
====
--
Martin Baulig
address@hidden (private)
address@hidden (work)
- scm_num2float() ?, Martin Baulig, 2001/09/01
- Re: scm_num2float() ?, Michael Livshin, 2001/09/01
- Re: scm_num2float() ?,
Martin Baulig <=
- Re: scm_num2float() ?, Michael Livshin, 2001/09/01
- Re: scm_num2float() ?, Martin Baulig, 2001/09/01
- Re: scm_num2float() ?, Marius Vollmer, 2001/09/02
- Re: scm_num2float() ?, Martin Baulig, 2001/09/02
- Re: scm_num2float() ?, Michael Livshin, 2001/09/02
- 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