I can do this in Erlang:
io:fwrite("~.16X~n", [-31,"0x"]).
-0x1F
ok
but not in Elixir:
:io.fwrite("~.16X~n", [-31,"0x"])
** (ArgumentError) argument error
(stdlib) :io.format(#PID<0.54.0>, "~.16X~n", [-31, "0x"])
Why not?
I can do this in Erlang:
io:fwrite("~.16X~n", [-31,"0x"]).
-0x1F
ok
but not in Elixir:
:io.fwrite("~.16X~n", [-31,"0x"])
** (ArgumentError) argument error
(stdlib) :io.format(#PID<0.54.0>, "~.16X~n", [-31, "0x"])
Why not?
Adding @Dogbert's comment as an answer:
Try using single quotes:
:io.fwrite('~.16X~n', [-31, '0x'])
A word of additional explanation: single quotes in Elixir indicate a character list (see here for more details). The Erlang fwrite function is expecting a list of characters not an Elixir binary hence the double quotes don't work while the single quotes do.