Fixed Point Decimal

A powerful feature is the ability to represent decimal numbers using a new data type, the fixed point decimal. Fixed point decimal gives you decimal representation, but at integer speed. This gives you a phenomenal speed boost over using float. This is accomplished with a qualifier: _fixed(x). The x is the number of digits after the decimal the data type can hold.

 

/*
Creates a 16 bit variable with a range of 0.00 to 655.35
*/

int16 _fixed(2) dollars;

/*
Assign 1.23 to dollars. Internally, 123 will be saved to the int16.
*/

dollars=1.23;

/*
Add 3.00 to dollars. Internally, 300 will be added to the int16.
*/

dollars += 3;

/*
printf will display 4.23
*/

printf("%w", dollars);