
Strings
57
Real numbers
Real numbers, numbers with a decimal part, are also known as floating point numbers.
ColdFusion real numbers can range from approximately -10
300
to approximately 10
300
. 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
x
E
y
, 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 10
y
. For example, 4.0E2 is 4.0 times 10
2,
which
equals 400. Similarly, 2.5E-2 is 2.5 times 10
-2
, which equals 0.025. Scientific notation is useful
for writing very large and very small numbers.
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.
There is, however, a 64K limit on the size of text data that can be read from and written to a
ColdFusion database or HTML text area. The ColdFusion MX 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 pound 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: "
Содержание ColdFusion MX
Страница 1: ...Developing ColdFusion MX Applications...
Страница 22: ...22 Contents...
Страница 38: ......
Страница 52: ...52 Chapter 2 Elements of CFML...
Страница 162: ......
Страница 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Страница 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Страница 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Страница 266: ......
Страница 314: ...314 Chapter 14 Handling Errors...
Страница 344: ...344 Chapter 15 Using Persistent Data and Locking...
Страница 349: ...About user security 349...
Страница 357: ...Security scenarios 357...
Страница 370: ...370 Chapter 16 Securing Applications...
Страница 388: ...388 Chapter 17 Developing Globalized Applications...
Страница 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Страница 410: ......
Страница 426: ...426 Chapter 19 Introduction to Databases and SQL...
Страница 476: ...476 Chapter 22 Using Query of Queries...
Страница 534: ...534 Chapter 24 Building a Search Interface...
Страница 556: ...556 Chapter 25 Using Verity Search Expressions...
Страница 558: ......
Страница 582: ...582 Chapter 26 Retrieving and Formatting Data...
Страница 668: ......
Страница 734: ...734 Chapter 32 Using Web Services...
Страница 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Страница 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Страница 788: ......
Страница 806: ...806 Chapter 35 Sending and Receiving E Mail...