Quote:
Originally Posted by
Iceman69
I have no clue on why this teacher wants us to use whole numbers in place of .03 for the tax.
Probably because most shells can't do math on numbers with decimal points. They'd either give a completely unexpected result, or discard the decimal points entirely.
Another reason whole numbers are used for finances is accuracy. Most languages which support decimal points use floating point numbers to do so, which actually have a fixed number of decimal places and multiply by 2^n to represent very large or very small numbers. This is a good approximation for math, but if you're dealing with finances, you might create headaches for accountants by being out quite a few cents here and there every time you add huge numbers of dollars.
How to use whole numbers instead of decimal points? Calculate everything in cents. No decimals needed (except maybe for printing).
How I'd convert decimal point to whole numbers is to multiply by 100... since you can't do that math on decimal-point numbers in the shell, use a number trick instead; split "13.42" into "13" and "42", make sure "42" is exactly two digits long, then stick them together into "1342". Voila, whole number in cents.
How to do this depends on your shell. What is it?