The value of an expression exported to text can be formatted. A formatting string is added immediately after the expression, using the syntax:
$(expression:formatting_string)
For example, to reduce the number of decimal places to two, use the formatting string “.2f”:
$(displayScale*3+10:.2f)
A formatting string always starts with a colon (:) and can contain the following parts, in order:
[Form][Filler][Overall length][.Precision][Format]
Form options
b : binary mode
- : align left
+ : print plus sign (numbers only)
Filler
Can be 0 or a space “ “
Works only if Form is not b (binary)
Default is space “ “
Overall length
A positive number
Works only if Form is not b
Format characters
c : byte in decimal
d : integer in decimal
x : integer in hexadecimal
f : floating-point number in decimal (32-bit)
e : floating-point number in exponential format (note: behaves the same as g)
g : floating-point number, automatically choosing between decimal and exponential form depending on which is shorter (supports up to 64-bit numbers)
Precision
Applies only to floating-point numbers (FLOAT or DOUBLE) when using f, e, or g
With format set to f, precision is the number of decimal places
With format set to e or g: precision is the total number of digits shown
When the Form is set to binary mode (b):
Filler, overall length, and precision are ignored and do not need to be specified
Format is mandatory and must be one of the following:
c : 1-byte integer
d, x : 4-byte integer
f : 4-byte floating-point number
e, g : 8-byte floating-point number
In all other modes, every part of the formatting string is optional.