Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting decimal to hex with Erlang?

Tags:

erlang

How to convert the decimal "37" to the hex Value "25" in Erlang? Is there a simple way?

like image 848
Filipe Santos Avatar asked May 12 '11 18:05

Filipe Santos


2 Answers

integer_to_list(Integer, Base) -> string() transforms an integer to a list of any base you supply: http://erldocs.com/18.3/erts/erlang.html?i=3&search=integer_to#integer_to_list/2

like image 192
kay Avatar answered Oct 21 '22 18:10

kay


A little simpler solution: httpd_util:integer_to_hexlist(Number) -> HexString

like image 25
Dmitry Avatar answered Oct 21 '22 19:10

Dmitry