driver_output_term() and unsigned long (32 bit) values
Per Bergqvist
per@REDACTED
Tue Jul 23 09:40:23 CEST 2002
Send it as a bignum.
Haven't really checked if this is supported via driver_output_term.
(If not it should be fixed...)
I do it via driver_output_binary and binary_to_term.
/Per
> Am I correct in assuming that, if I *really* needed a driver to get
> the most-significant bit of a 32 bit unsigned long sent to Erlang
via
> driver_output_term(), I'm out of luck?
>
> I suppose I could do something like:
>
> 1. Modify BEAM to support unsigned integers.
> 2. Send the unsigned int back as a binary and then unpack it as an
> ":32/unsigned-integer"
> 3. Send the unsigned int back as a signed int, then have Erlang pack
> it into a binary and then unpack it as a ":32/unsigned-integer".
> 4. Send back a {1, N} tuple and then have Erlang convert via "(1 bsl
> 31) bor N" or equivalent arithmetic.
> 5. Not use driver_output_term().
> 6. Um, I think I'd better stop now. This is getting too ugly.
>
> Is there a better, non-ugly solution I'm missing?
>
> -Scott
>
=========================================================
Per Bergqvist
Synapse Systems AB
Phone: +46 709 686 685
Email: per@REDACTED
More information about the erlang-questions
mailing list