CFLib.org – Common Function Library Project

DecToHex(str)

Last updated November 6, 2001

author

Rob Brooks-Bilson

Version: 1 | Requires: CF5 | Library: MathLib

Description:
Converts from decimal (base10) to hexadecimal (base16). Provides a wrapper around the BIF FormatBaseN. Converts both positive and negative numbers.

Return Values:
Returns a string.

Example:

<CFSET x=1000>
<CFSET y=-1000>
<CFOUTPUT>
#x# represented in hexadecimal is: #DecToHex(x)#<BR>
#y# represented in hexadecimal is: #DecToHex(y)#<BR>
</CFOUTPUT>

Parameters:

Name Description Required
str Decimal number to convert to hexadecimal. Yes

Full UDF Source:

/**
 * Converts from decimal(base10) to hexadecimal (base16).
 * 
 * @param str 	 Decimal number to convert to hexadecimal. 
 * @return Returns a string. 
 * @author Rob Brooks-Bilson (rbils@amkor.com) 
 * @version 1, November 6, 2001 
 */
function DecToHex(str){
  return Ucase(FormatBaseN(str, 16));
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson