You can perform financial calculations in OmniMark using the BCD data type to represent monetary values and fractional numbers such as tax rates. Unlike floating point numbers, BCD numbers provide accurate fractions for financial calculations.
The following code sample shows basic financial calculations using BCD numbers.
import "ombcd.xmd" unprefixed process local integer quantity local bcd price local bcd tax-rate local bcd total set quantity to 28 set price to 19.95 set tax-rate to 0.07 set total to price * quantity * (1 + tax-rate) output "<$,NNZ.ZZ>" % total || "%n"
The format string
<$,NNZ.ZZ> uses the BCD template
language to create an output string with a leading
$, commas separating digits into groups
of three, and two digits after the decimal point.