3 ms·
An integer of the smallest denomination. For example, cents for the American dollar. And you probably would want to wrap it in a custom type to simplify display
by thayne 5y ago
An integer of the smallest denomination. For example, cents for the American dollar. And you probably would want to wrap it in a custom type to simplify displaying it properly, and maybe handle different currencies. If you language has a fixed point type that might also be appropriate, but that's pretty rare, and wouldn't work for currencies that aren't decimal (like the old british pound system).
- biztos 5y agoDo they still use fractional cents (or whatever) in finance? https://money.howstuffworks.com/personal-finance/financial-planning/stock-market-use-fractions.htm https://money.howstuffworks.com/personal-finance/financial-p...
- TchoBeer 5y agoWhat if I'm calculating sales tax? Can't use an integer anymore.
- kyllo 5y agoYes, you can. There are algorithms for rounding up, rounding down, rounding to nearest, and banker's rounding, on the results of integer division. This is a solved problem.