How to convert typescript number to Hex?

John Baird picture John Baird · Sep 13, 2016 · Viewed 11.1k times · Source

I have googled for the past hour and can't find anything on typescript conversion of number to hex. The javascript solutions don't work.

How can I turn 100 into its hex representation using typescript?

Answer

McNultyyy picture McNultyyy · Sep 13, 2016

toString(16) is what you're looking for.

var g: number = 255;
alert(g.toString(16));