Should you decide to follow the (good) suggestion given by ozo, be sure to use __int64 rather than int, because otherwise an overflow may occur on bigger sums of money. If __int64 is not an option, at least use unsigned int (its numeric limit is pow(2,32) which is over 4 billion as opposed to around 2 billion for int; it means you can use unsigned to process sums up to 40 mln dollars).
Main Topics
Browse All Topics





by: ozoPosted on 2008-04-08 at 18:05:39ID: 21311068
Rounding rules for taxes may vary by jurisdiction, but you probably shouldn't trust floating point numbers to do it
you could take 6900 cents * 65 = 448500 / 1000 cents rounded to 449000 / 1000 cents