From: Waldek H. <he...@ma...> - 2010-04-10 19:14:11
|
Christophe Rhodes wrote: > Paul Khuong <pv...@pv...> writes: > > > In article <871...@ca...>, > > Christophe Rhodes <cs...@ca...> wrote: > >> I'm not sure why you think this is curious. It sounds like Waldek is > >> saying that the in-memory representation of an sbcl bignum is > >> sufficiently close to an in-memory representation of a gmp bignum that > >> it's possible to pun them. The disadvantage of doing a principled > >> translation between GMP structures and Lisp bignums is... > > > > It's not, unless you restrict yourself to positive integers. GMP integer > > use a sign-magnitude representation, while we use 2's complement, > > probably to simplify bit operations. > > Well, that's a shame :-) Oh well. > > Then sb-alien can be used to write support routines for automatic > conversion to and from the GMP representation: defining alien type class > methods for naturalize-gen and deport-gen (look at the c-string methods > for inspiration). This would allow Waldek to have an integrated feel > for whatever GMP calls he needs to make, I think. > I am using sb-bignum::negate-bignum and sb-bignum::negate-bignum-in-place (if appropriate). I am not sure how much automation is possible (and worthwhile). I am interfacing to mpn routines, there is only handful of them but interfaces are irregular. -- Waldek Hebisch he...@ma... |