driver_output_term() and unsigned long (32 bit) values

David Gould <>
Sat Jul 27 02:48:59 CEST 2002


On Sat, Jul 27, 2002 at 01:25:38AM +0200, Raimo Niskanen wrote:
> Scott Lystig Fritchie wrote:
> > 
> > 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".
> 
> 3b. Send the unsigned int back as a signed int, then if the returned
> value is negative: add (1 bsl 32), otherwise it is correct.
> 
> This assumes a 32 bit 2-complement machine. A portability freak would
> first find the wordsize in some way (for the day a 64-bit Erlang port
> comes), but I do not think non 2-complement machines even exist nor ever
> will. 

Univac 1100 series. Ones complement, 36 bit words, either 9 bit ascii or
6 bit "Fieldata" character set depending on whether in "quarterword mode" or
"thirdword mode".  There may even be some still in use.
If you think x86 is ugly and baroque, you have not worked on a Univac!

For some more amusement and edification see:

  http://www.fourmilab.ch/documents/univac/

I had the pleasure of working on an 1108 for a year so, a long time ago,
(never mind exactly how long!).


-dg

-- 
David Gould                                    
If simplicity worked, the world would be overrun with insects.



More information about the erlang-questions mailing list