Hacker News new | past | comments | ask | show | jobs | submit login

Don't use int for money. Use BigDecimal.

I know performance is an issue, but you can always find non-hackish solutions: like a memory upgrade from management, because you're writing safe, clean code :-)




BigDecimal uses 10 times as much memory as an int but I didn't intend to properly model currency amounts anyway.



Any sane developer will track money in lowest units - eg cents. Rather than Dollars.


A sane developer is as rare as a sufficiently smart compiler.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: