Return to Snippet

Revision: 52735
at November 1, 2011 04:22 by adrianparr


Initial Code
function decimalToHex($decimal:int, $padding:int = 2):String {
	var hex:String = Number($decimal).toString(16);
	while (hex.length < $padding)
	{
		hex = "0" + hex;
	}
	return hex.toUpperCase();
}

var decimal:int = 163;
trace("decimal: " + decimal);
var hex:String = decimalToHex(decimal, 4);
trace("hex: " + hex);

// OUTPUT
// decimal: 163
// hex: 00A3

Initial URL

                                

Initial Description

                                

Initial Title
AS3 Decimal To Hex

Initial Tags
number

Initial Language
ActionScript 3