On May 22, 2007, at 12:33 PM, Dan Muresan wrote:


<snip>

Actually, I haven't found the 31-bit format documented anywhere (maybe I missed it). I thought that at least normal C int's would always fit in a fixnum. It was an unpleasant surprise to see an expression like (logior flags ...) fail, when "flags" was promoted to a flonum.

If you use one of integer unsigned-integer integer32 unsigned- integer32 integer64 long unsigned-long as a foreign parameter/ return type Chicken will automatically convert a flonum integer to/ from the native type.

Yes, but flonum's can't be used in some contexts:

* bit ops

* modulo-2^32 arithmetic (i.e. C-like 32-bit wraparound arithmetic)

I don't see a way to hack these using flonums. Bignums would solve the problem but they're slow.

The bitwise-* procedures & arithmetic-shift are supposed to work w/ fixnums & integer flonums. The magnitude of a flonum is converted to a C unsigned int (on 32 bit machines, u_int64_t otherwise), operated upon, then the result is returned as a fixnum or flonum, depending on the precision of the operation result.

The modulo-2^32 is a problem though.

Sorry,
Kon


<snip>



_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to