Signed integers

Chandrashekhar Mullaparthi chandrashekhar.mullaparthi@REDACTED
Tue Dec 23 12:58:09 CET 2003


All,

to_signed_int(Int, NumOctets) when integer(Int) ->
    NumBits = NumOctets * 8,
    <<SignedInt:NumBits/signed-integer>> = <<Int:NumBits>>,
    SignedInt.

1> etopup_worker:to_signed_int(65535, 2).
-1

Is there a better way to convert unsigned integers to signed integers?

cheers
Chandru




More information about the erlang-questions mailing list