Values

Values are the smallest elements of an expression. The values may be of the following type:

Reference To Previous Result

The @ character can be used on its own to reference the result of the previous calculation. The final result is taken into account; intermediate results are not. If there was no previous result stored, the value is null. The reference is useful when you need to re-use the same result multiple times in an expression.

Numbers

ABCalc supports signed and unsigned integer and floating-point numbers of arbitrary size.

A number may contain number group separators (characters that split groups of three digits) and underscore ('_'). The latter is used for readability, is allowed at any position of the number.

Additionally, a number may be accompanied by the currency indicator as described below.

Integer numbers

Integer numbers can be written in decimal, hexadecimal, binary, or octal forms as shown below. Numbers in decimal format may include a leading sign ('-') character to indicate negative numbers.

Examples:

123456 // decimal
0xFFFF // hexadecimal
0o1777 // octal
0b01010101 // binary
0xBE______EF // still a valid number
123,456 // a valid integer if your number group separator is comma

Floating-point Numbers

Floating-point numbers may be written in the standard or scientific notation. The decimal separator (a character used to split whole and fractional parts) is taken from system regional settings by default, but you can change it in the ABCalc settings. You can also specify a second separator there. For example, if your regional separator is ',' but you work with texts or data coming from the country where '.' is a separator, you can set the '.' for a second separator.

Note: if your selected keyboard layout is Programmer's, the '.' (dot) is used for a decimal separator.

Examples:

123,456 // when comma is a decimal separator
.123
123.0

1E-2
1e+2
1.5E18

Percent

Percent values are written as "x%" where x is a number (or an expression that evaluates to a number). The meaning of such a value does not differ from the current use of percent. I.e., you can write "100+5%" in an expression and get 105. Percent values also may be passed to some functions that expect them. Note that when passing a percent to a function, you multiply the regular fractional value by 100, i.e., you can pass just "0.05" for an argument or pass "5%".

Currency

A currency indicator may be present before or after an integer or a floating-point number. ABCalc accepts the currency of the system regional settings as a symbol (e.g., $) or an abbreviation (e.g., USD). The indicator itself is ignored and is accepted for convenience of pasting numbers that denote money sums.

Date and Time

ABCalc is one of the few (if not the only) calculators that support mathematical operations with date and time in the expressions.

A time period can be added and subtracted to/from another time period or to/from a date. Time periods can also be multiplied and divided by a number. A date can be subtracted from another date.

When you specify a date, a date with time, or a time period, the value must be provided in one of forms described below and must be enclosed in # (see the examples below). The format for recognizing a date/time is taken from system regional settings. In addition, the ISO 8601 format is supported, and it does not depend on the regional settings. This format is the most convenient when you need to construct a date-time value.

Time may be specified with or without seconds. For US and other 12-hour times, am/pm and a/p designators are recognized.

Dates and time periods are specified by writing them in a humane manner, where number values are written in digits, and the type of period is written in words, either in full or abbreviated forms. The words are localizable (translated to different languages available in the interface), and if the user interface of ABCalc is set to a language different from English, you can use the words in the language of the interface or English words.

For dates, you can write "now" or "today" (words without quotes) for current date and time or just date respectively, whereas "yesterday" and "tomorrow" can be used to denote the previous and the next day (without time).

Examples of dates:

#15.12.2020# - common European format
#15. 12. 2020# - the same but with spaces after dots as used in some european countries
#15.12.2020 10:10:05# - the same with time
#2020-12-15# - Date in ISO 8601 format 
#2020-12-15T10:10:05Z# - Date and time in ISO 8601 format 

#yesterday# - subtracts exactly 24 hours from the current moment
#tomorrow# - adds exactly 24 hours to the current moment
#5 years ago# - subtracts 5 years from the current moment
#before 5 years# - also works and also subtracts 5 years from the current moment
#in 3 days# - adds exactly 72 hours to the current moment
#3 days later# - the same as "in 3 days"

Examples of time periods:

#5:00# - five hours (seconds omitted)
#00:03:00# - three minutes
#2.12:00:00# - two days and twelve hours
#5 minutes 30 seconds# - this works
#5 min 30 sec# - also works
#5 m 30 s# - works too
#3 years 1 day# 

A time period can be converted to milliseconds using the TimeToMS() function, which enables further math operations with it. The MSToTime() function lets you perform the opposite conversion.

Note: dates and time periods as values are evaluated at the moment of parsing of the expression. This is important for Custom Functions which are loaded and parsed by ABCalc long before they are used. There, if you use "#today#" or "#now#" to denote current date or date and time, the time at the moment of parsing will be taken, and if the function is called the next day, it will produce an unexpected value. To address this situation, ABCalc offers Today() and Now() functions which can be used in custom functions.

Boolean values

Boolean values are written simply as true or false without quotes. The values are not case-sensitive, so writing True or FALSE is fine. Functions that expect a boolean argument also accept integer numbers and convert a non-zero integer to true and zero to false.

Characters

A single character enclosed in single quotes is treated as a character type, although it can be handled like a string when necessary. A character can be passed to functions which expect a character in an argument.

Strings

Strings are sequences of characters enclosed in single quotes ('), double quotes ("), or backquotes (`).

Examples:

"A string"
'Another string'

Strings enclosed in quotes or double-quotes are decoded during parsing, with the following sequences being replaced:

\' becomes a ' (single quote)
\" becomes a " (double quote)
\\ becomes a \ (backslash)
\n becomes a new line
\t becomes a Tab
\uXXXX becomes a character with a unicode code XXXX (hexadecimal)
\xXXXX becomes a character with a unicode code XXXX (hexadecimal)

To prevent decoding, use backquotes or prefix a string enclosed in double quotes with an @ ("at") character.

Examples of non-decodable strings:

@"This string is not decoded, so \n is not a new line but a backslash followed by 'n' (and note single quotes!) "
`This string is not decoded, and you can use "double quote" characters in it`

A string can be specified explicitly as shown below or using the MakeString() function to construct a string.

You can concatenate strings using the + operator. ABCalc also includes a range of string functions to further manipulate strings.

Individual characters are accessed by index, where the index may be an integer number or an expression which evaluates to a number: "abc"[1] will yield 'b'.

A slice of a string can be taken by specifying the lower and/or upper boundary (indices in this notation are zero-based):

"abc"[0..1] - yields ('ab')
"abc"[..1] - yields ('ab')
"abcd"[2..] - yields ('cd')
"abcd"[..^2] - yields ('abc')

Lists

Lists are widely used in ABCalc. You specify a list by enclosing several values, separated with ; (semicolon) into a pair of parentheses (a comma can be used as a separator, but it may conflict with decimal separators or number group separators, causing problems). The elements of the list are not generally required to be of the same type, although most built-in functions which work with lists expect lists of numbers.

You can specify a list explicitly:

(1; 2; 3)

or use the MakeList() function.

Individual elements are accessed by index, where the index may be an integer number or an expression which evaluates to a number: ('a'; 'b'; 'c')[1] will yield 'b'.

A slice of a list can be taken by specifying the lower and/or upper boundary:

('a'; 'b'; 'c')[0..1] - yields ('a'; 'b')
('a'; 'b'; 'c')[..1] - yields ('a'; 'b')
('a'; 'b'; 'c'; 'd')[2..] - yields ('c'; 'd')
('a'; 'b'; 'c'; 'd')[..^2] - yields ('a'; 'b'; 'c')

Constants

ABCalc includes some predefined constants:

  • pi (3.14...you know the rest)
  • e (2.71...)
  • phi (golden ratio, 1.618...)
  • unit_XXX where XXX is the unit name. Please refer to the description of the Convert() function for the list of unit names.

You can use any such constant the same way you'd use a number or other value in an expression.