Investment Studio > Expressions > Constants

Constants are explicit values available to expressions without computation. They can be booleans, integers, floats or strings and can be arranged in arrays.

Boolean constants

There are only two boolean constants: TRUE and FALSE. Since identifiers are not case sensitive, the following expressions are all equivalent:

=TRUE

=True

=not false

=not FALSE

A trivial example using the spreadsheet in the Macros view:

Note the absence of quotation marks in the expression. If it were enclosed in quotation marks, TRUE would be a string constant. Symbolic constant names in strings are not automatically converted to the corresponding constant values, so this doesn't work:

On the other hand, since booleans are derived from integers, the string to integer conversion rules do apply:

Integer constants

Whole numbers within the integer range can be entered as integer constants:

Whole numbers outside the range of the integer data type are interpreted as float constants.

Note the absence of quotation marks in the above example. If it were enclosed in quotation marks, 2147483647 would be a string constant.

The character serving as thousands separator depends on the computer's regional settings. The use of thousands separators in strings representing integers should therefore be avoided.

When expressions are saved to disk, a portable format is used for all numeric constants. This guarantees that numbers (as opposed to strings representing numbers) will be unaffected even if the computer's regional settings are changed, or if files containing expressions are moved to a computer with different settings.

Float constants

There are two symbolic float constants:

PI

The ratio of a circle's circumference to its diameter. Approximated as 3.14159265358979. The same value is returned by the function pi.

Since identifiers are not case sensitive, the following expressions are all equivalent:

=PI

=Pi

=pi

Note the absence of quotation marks. If it were enclosed in quotation marks, PI would be a string constant. Symbolic constant names in strings are not automatically converted to the corresponding constant values, so the string "PI" has no valid interpretation as a float.

E

Euler's number: the base of the natural logarithms. Approximated as 2.71828182845905. The same value is returned by the expression

=EXP(1.0)

(see function EXP). Since identifiers are not case sensitive, the following expressions are equivalent:

=E

=e

Note the absence of quotation marks. If it were enclosed in quotation marks, E would be a string constant. Symbolic constant names in strings are not automatically converted to the corresponding constant values, so the string "E" has no valid interpretation as a float.

Floating point numbers within the float range can be entered as ordinary float constants:

Note the absence of quotation marks in the above example. If it were enclosed in quotation marks, 1.2 would be a string constant.

Scientific notation is supported:

In the above example, 1.2 is the mantissa; the characted "e" (or, equivalently, "E") separates it from the exponent; and -1 is the exponent (of 10, implied) itself. Hence, 1.2e-1 = 1.2 x 10^-1.

The characters serving as decimal and thousands separators depend on the computer's regional settings. The use of strings representing floating point numbers should therefore be avoided.

When expressions are saved to disk, a portable format is used for all numeric constants. This guarantees that numbers (as opposed to strings representing numbers) will be unaffected even if the computer's regional settings are changed, or if files containing expressions are moved to a computer with different settings.

String constants

String constants start with double quotation marks ("). All characters following (but not including) the start mark, up to (but not including) the next quotation mark constitute the constant's value. Closing quotation marks are optional. Therefore, the expressions

="This is a string constant."

and

="This is a string constant.

are equivalent.

There is no way to include quotation marks in the value of a string constant. Instead, you can use the concatenation operator (&) and the CHAR function to build string expressions containing quotation marks:

While it's possible to use string constants to hold numeric values (e.g. dates) and rely on automatic conversion for their interpretation, this practice is better avoided. That's because string representations of integers, floats, dates and times depend on the computer's regional settings and may change unexpectedly between sessions.

It is not advisable to code numeric values as strings in your expressions. Numeric constants should always be entered as numbers.