How to convert typescript number to Hex?

14,040

Solution 1

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

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

Solution 2

As found on http://www.c-sharpcorner.com/UploadFile/5089e0/number-object-method-in-typescript-part-41/

number.toString(16);
Share:
14,040
John Baird
Author by

John Baird

Updated on June 05, 2022

Comments

  • John Baird
    John Baird about 2 years

    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?