[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Integer conversion proposal
From: |
Gary Houston |
Subject: |
Re: Integer conversion proposal |
Date: |
23 Sep 2001 14:37:19 -0000 |
> From: Dirk Herrmann <address@hidden>
> Date: Sun, 23 Sep 2001 11:07:46 +0200 (MEST)
>
> Which target types should we support? Maybe we could restrict ourselves
> to a small set of target types based on the following considerations:
>
> * IIRC, the type 'int' is considered the type that represents a machine's
> 'natural' word length. (Correct me if I am wrong). Thus, we should
> provide a conversion to int and uint.
>
> * C99 introduces a typedef that corresponds to the 'largest' supported
> integral type. (I don't know the name of that type any more). We
> should also provide a conversion to this type and the corresponding
> unsigned one.
>
> In principle, those two integral types would be sufficient. All other
> conversions could be done manually by the users:
Only up to a point, e.g., socket.c deals with 128 bit integers, it
just happens that the C compiler doesn't support them directly. It
would be nice to have a couple of more general versions of these
functions, for signed and unsigned integers:
void scm_num2sint (size_t size, SCM src, void *dest);
void scm_num2uint (size_t size, SCM src, void *dest);
which could be used like:
size_t
num2size_t (SCM src)
{
size_t result;
scm_num2uint (sizeof result, src, &result);
return result;
}