Bookshelf Home | Contents | Index | PDF |
Siebel eScript Language Reference > Siebel eScript Language Overview > Data Types in Siebel eScript > Numbers in Siebel eScriptThis topic describes the various notations for numeric literals. NOTE: The notations provided in this section are not data types and should not be used as data types in declarations for strongly typed variables. NOTE: Numbers that contain characters other than a decimal point, except in hexadecimal and scientific notation, are treated as string values in eScript. For example, eScript treats the number 100,000 (notice the comma) as a string. IntegerIntegers are positive and negative whole numbers and zero. Integer constants and literals can be expressed in decimal, hexadecimal, or octal notation. Decimal constants and literals are expressed by using the decimal representation. See the following two sections to learn how to express hexadecimal and octal integers. NOTE: A variable cannot be strongly typed as an integer. You can use the primitive type float, and it's value can be used as an integer. HexadecimalHexadecimal notation uses base-16 digits from the sets of 0-9 and A-F or a-f. These digits are preceded by 0x. Case sensitivity does not apply to hexadecimal notation in Siebel eScript. Examples are: 0x1, 0x01, 0x100, 0x1F, 0x1f, 0xABCD 1, 1, 256, 31, 31, 43981 OctalOctal notation uses base-8 digits from the set of 0-7. These digits are preceded by a zero. Examples are: Floating PointFloating-point numbers are numbers with fractional parts that are indicated by decimal notation, such as 10.33. NOTE: Floating-point numbers are often referred to as floats. Do not confuse the familiar connotation of float with the eScript float primitive data type. CAUTION: The assignment of a floating-point number to a variable may cause a loss in precision due to a limit in memory for decimal-to-binary conversion. Numbers that may be stored with a small precision error are decimal numbers that do not convert to a finite binary representation. For example, the statement var x = 142871.45 may result in x being stored as 142871.450000000001. These small precision errors will likely have little effect on precision of subsequent calculations, depending on their context. However, a number's representation may be unexpectedly too large for the field in which it displays, resulting in the error message "Value too long for field %1 (maximum size %2)." To prevent floating-point precision errors, use the toFixed() Method at appropriate points in calculations or when assigning variable values. For example, use x.toFixed(2) in calculations instead of using variable x as declared above. DecimalDecimal floats use the same digits as decimal integers but use a period to indicate a fractional part. Examples are: 0.32, 1.44, 99.44 ScientificScientific notation is useful in expressing very large and very small numbers. It uses the decimal digits in conjunction with exponential notation, represented by 4.087e2, 4.087E2, 4.087e+2, 4.087E-2 408.7, 408.7, 408.7, 0.04087 NaNNaN means "not a number," and NaN is an abbreviation for the phrase. NaN is not a data type, but is instead a value. However, NaN does not have a literal representation. To test for NaN, the function, isNaN(), must be used, as illustrated in the following fragment: var Test = "a string"; When the parseInt() function tries to parse the string Number Constants in Siebel eScriptSeveral numeric constants, as shown in Table 4, can be accessed as properties of the Number object, though they do not have a literal representation.
|
Siebel eScript Language Reference |