Help Center

CMoney.Math operatorsoperator

Add, subtract, multiply or divide currency numbers.

Numeric Datatypesoperatordoc-orphan
No implementation located. This member is documented, but the source scan found no matching declaration. It is likely declared in a header this scan does not resolve, or provided by a macro.

Syntax

OPERATOR + (BYREF cur1 AS CMoney, BYREF cur2 AS CMoney) AS CMoney
OPERATOR += (BYREF cur AS CMoney)
OPERATOR - (BYREF cur1 AS CMoney, BYREF cur2 AS CMoney) AS CMoney
OPERATOR -= (BYREF cur AS CMoney)
OPERATOR * (BYREF cur1 AS CMoney, BYREF cur2 AS CMoney) AS CMoney
OPERATOR *= (BYREF cur AS CMoney)
OPERATOR / (BYREF cur AS CMoney, BYVAL cOperand AS CMoney) AS CMoney
OPERATOR /= (BYREF cOperand AS CMoney)

Remarks

The version OPERATOR - (BYREF cur AS CMoney) AS CMoney changes the sign of a currency number.

Or you can use the NOT operator:

Other FreeBasic operators such AND, MOD, OR, SHL and SHR can also be used with CMoney variables, e.g. c = c AND 1, c = c MOD 5, etc.

Examples

DIM c AS CMoney = 12345.1234 c = c + 111.11 c = c - 111.11 c = c * 2 c = c / 2 c += 123 c -= 123 c *= 2.3 c /= 2.3

DIM c AS CMoney = 123 c = -c

DIM c AS CMoney = 123 c = NOT c

Reference

  • Documented in Numeric Datatypes/CMoney Class.md
  • Topic: CMoney Class