Adobe COLDFUSION 9 Manual page 47

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Real numbers
Real numbers, numbers with a decimal part, are also known as floating point numbers. ColdFusion real numbers can
range from approximately -10300 to approximately 10300. A real number can have up to 12 significant digits. As with
integers, you can assign a variable a value with more digits, but the data is stored as a string. The string is converted to
a real number, and can lose precision, when you use it in an arithmetic expression.
You can represent real numbers in scientific notation. This format is xEy, where x is a positive or negative real number
in the range 1.0 (inclusive) to 10 (exclusive), and y is an integer. The value of a number in scientific notation is x times
10y. For example, 4.0E
is 4.0 times 10
2
Scientific notation is useful for writing very large and very small numbers.
BigDecimal numbers
ColdFusion does not have a special BigDecimal data type for arbitrary length decimal numbers such as
1234567890987564.234678503059281. Instead, it represents such numbers as strings. ColdFusion does, however, have
a PrecisionEvaluate function that can take an arithmetic expression that uses BigDecimal values, calculate the
expression, and return a string with the resulting BigDecimal value. For more information, see PrecisionEvaluate in
the CFML Reference.
Strings
In ColdFusion, text values are stored in strings. You specify strings by enclosing them in either single- or double-
quotation marks. For example, the following two strings are equivalent:
"This is a string"
'This is a string'
You can write an empty string in the following ways:
• "" (a pair of double-quotation marks with nothing in between)
• '' (a pair of single-quotation marks with nothing in between)
Strings can be any length, limited by the amount of available memory on the ColdFusion server. However, the default
size limit for long text retrieval (CLOB) is 64K. The ColdFusion Administrator lets you increase the limit for database
string transfers, but doing so can reduce server performance. To change the limit, select the Enable retrieval of long
text option on the Advanced Settings page for the data source.
Escaping quotation marks and number signs
To include a single-quotation character in a string that is single-quoted, use two single-quotation marks (known as
escaping the single-quotation mark). The following example uses escaped single-quotation marks:
<cfset myString='This is a single-quotation mark: '' This is a double-quotation mark: "'>
<cfoutput>#mystring#</cfoutput><br>
To include a double-quotation mark in a double-quoted string, use two double-quotation marks (known as escaping
the double-quotation mark). The following example uses escaped double-quotation marks:
<cfset myString="This is a single-quotation mark: ' This is a double-quotation mark: """>
<cfoutput>#mystring#</cfoutput><br>
Because strings can be in either double-quotation marks or single-quotation marks, both of the preceding examples
display the same text:
This is a single-quotation mark: ' This is a double-quotation mark: "
To insert a number sign (#) in a string, you must escape the number sign, as follows:
, which equals 400. Similarly, 2.5E
2
Last updated 8/5/2010
is 2.5 times 10
, which equals 0.025.
-2
-2
42

Advertisement

Table of Contents
loading

Table of Contents