convert a tuple or list to 4 byte integer value
Serge Aleynikov
serge@REDACTED
Fri Aug 5 22:04:09 CEST 2005
Try this:
10> <<I:32>> = <<47,80,18,222>>.
<<47,80,18,222>>
11> I.
793776862
12> <<I:32>>.
<<47,80,18,222>>
Serge
MEENA SELVAM wrote:
> I have an IPaddress tuple {47,80,18,222} or after
> conversion using tuple_to_list I have [47,80,18,222]
>
> But the snmp object type to hold this ip address is
> 'IpAddress' which is 4 bytes of integer.
>
> I tried, list_to_integer[47,80,18,222] which gives a
> badarg error,
>
> 1> list_to_integer([47,80,18,222]).
> ** exited:
> {badarg,[{erlang,list_to_integer,[[47,80,18,222]]},
> {erl_eval,do_apply,5},
> {shell,exprs,6},
> {shell,eval_loop,3}]} **
>
> =ERROR REPORT==== 5-Aug-2005::12:02:17 ===
> Error in process <0.30.0> with exit value:
> {badarg,[{erlang,list_to_integer,[[47,80,18,222]]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
>
>
> But actually what I need is, not the ascii equivalent.
> I need to convert this to 4 bytes one with 47, one
> with 80
>
> How can I do this?
>
> meena
More information about the erlang-questions
mailing list