View comments | RSS feed

FormatBaseN

Description

Converts number to a string, in the base specified by radix.

Returns

String that represents number, in the base radix.

Category

Display and formatting functions, Mathematical functions, String functions

Function syntax

FormatBaseN(number, radix)

See also

InputBaseN

Parameters

Parameter Description

number

Number to convert

radix

Base of the result

Example

<h3>FormatBaseN Example</h3>
<p>Converts a number to a string in the base specified by Radix.
<p>
<cfoutput>
<br>FormatBaseN(10,2): #FormatBaseN(10,2)#
<br>FormatBaseN(1024,16): #FormatBaseN(1024,16)#
<br>FormatBaseN(125,10): #FormatBaseN(125,10)#
<br>FormatBaseN(10.75,2): #FormatBaseN(10.75,2)#
</cfoutput>
<h3>InputBaseN Example</h3>
<p>InputBaseN returns the number obtained by converting a string, 
using base specified by Radix (an integer from 2 to 36). <cfoutput> <br>InputBaseN("1010",2): #InputBaseN("1010",2)# <br>InputBaseN("3ff",16): #InputBaseN("3ff",16)# <br>InputBaseN("125",10): #InputBaseN("125",10)# <br>InputBaseN(1010,2): #InputBaseN(1010,2)# </cfoutput>

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


ianchia said on Feb 10, 2005 at 7:57 PM :
InputBaseN under CFMX6.1 doesn't accept long 32 hex numbers. (Unsure about CFMX7).

The following code:

<cfset hash = "28EFD7DB3476EC37B0921108C3E32FD2">
<cfset hash_dec = InputBaseN(hash,16)>
<cfset hash_36 = FormatBaseN(hash_dec,36)>

Invalid argument for function InputBaseN.
The argument 1 of InputBaseN which is now "28EFD7DB3476EC37B0921108C3E32FD2" must be a valid number in base 16.

Shortening the 32 char hex string to a 16 string hex number works. Hence, you can't use CreateUUID to create a UID which could be shorted to base 36 as a short string hash.
FlexAuthority.com said on Sep 24, 2005 at 10:51 PM :
From ColdFusion 7 -
Parameter validation error for function FORMATBASEN.
The value of the parameter 1, which is currently "999999999999", must be a int value.

The docs says it takes a number - but it is really looking for an int. (which gets capped at 2,147,483,647.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000467.htm