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

I'm a bit surprised to see floating point being used for multiplication, division etc. I would have expected to see this implemented with integers as well (with each operation changing the position of the point).



Floating point multiplication can be faster than integer multiplication on modern CPUs. Check out this thread for lots of info!

https://stackoverflow.com/q/2550281/164234


When people consider float vs int, performance is seldom a relevant factor.

You have to ask, what do you even mean if you use floating point for representing money?

If you use floating point, the whole point is that you want the behaviour

1e100 = 1e100 + 1

This is exactly what you want for many analysis and decision making problems, but it is a dangerous default.




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

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

Search: