MONEY

MONEY  is a numeric data type used to store currency amounts. The values of MONEY data type are stored as fixed-point numbers that can have up to 32 significant digits. You can use MONEY(p, s) format to specify the precision and scale. The default number of decimal places for MONEY data type is 2, this means that if you declare MONEY(p) data type, it will be stored as DECIMAL(p, 2). The precision can be from 1 to 32. The MONEY data type cannot be stored as a floating point number.

 

If no precision and no scale is specified the default parameters are applied; by default the precision is 16, the scale is 2. The largest absolute value that can be stored with the help of the MONEY data type is 10p-s -10-s (where p is the precision and s is the scale).

 

Values less than 0.5×10-s (where s is the scale) are stored as zeros. It is not possible to define a precision for a form field of MONEY data type, here the default precision will be used, it is smaller than 32 and is equal to (length of the filed – 2).

 

Values of MONEY data type are displayed with the currency symbol, by default it is a dollar sign ($), and decimal places are separated with the help of the decimal point. No currency symbol should be entered by the user into form fields of MONEY type or used in 4GL statements in literal MONEY values. The display format can be changed using the DBMONEY or DBFORMAT variable. The settings used in these variables override the default settings of the locale.

 

To calculate the amount of bytes needed to store a MONEY value, use the formula for DECIMAL data type:

For even scale:

 

 

For odd scale:

 

 

E.g. MONEY(10,2) will need ((10 + 4) /2) = 7 bytes of storage.

 

 

 

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.