[CLN-list] Patch to convert cl_I to and from a byte stream

Igor Khavkine igor.kh at gmail.com
Fri Aug 11 19:10:16 CEST 2006


Hello,

Recently, I've had to use CLN in conjunction with GiNaC.
Unfortunately, I've found that it's hard to pass numbers from
applications that use CLN to applications that use other libraries,
such as GMP or Python. The most efficient method I've found is through
a base-16 or base-32 string representation.

I think the conversion would be much simpler if CLN could export its
numbers as byte streams (basically in base-256), say little endian and
signed. Conversion through this intermediate format would then simply
be a matter of memory copying together with some fiddling that each
library has to do to construct its internal number representation.

I've written a few simple routines that allow the conversion based on
the conversion to and from a digit sequence (DS) that CLN already
supports (although does not export). I'm attaching a patch with these
routines. Please consider adding it to the next CLN release.

As is, the patch probably needs some work to seamlessly fit into the
library. For instance, I'm sure some of the code could be shortened if
some of the internal CLN macros for working with different endian
storage schemes were used. For another thing, I'm not sure where to
place the prototypes of these routines to add them to the library's
exported interface.

Thanks.

Igor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cln-bytes.diff
Type: application/octet-stream
Size: 0 bytes
Desc: not available
Url : http://www.cebix.net/pipermail/cln-list/attachments/20060811/a5499c49/cln-bytes.obj


More information about the CLN-list mailing list