4 ms·
> If you design software that works with money amounts, always use fixed point decimals. Don't use floats, it's just wrong! Don’t write with such certainty! D
by Kon-Peki 4y ago
> If you design software that works with money amounts, always use fixed point decimals. Don't use floats, it's just wrong!
Don’t write with such certainty! Decimal math is great advice for many/most situations, but what if you have a LOT of numbers and not a lot of time? That big number crunching GPU is not available if you take this approach.
Numerical Methods was the most difficult CS course I took in university and also the one I did the worst in. And of course it was an elective, or else they wouldn’t have graduated many people at all. If you’re doing a lot of number crunching stuff, maybe you should ask people that know how to number crunch to design your system so it has the smallest errors :)
PS - I’m not the person for that job!
- t8sr 4y agoI am almost completely certain that neither Google Sheets, nor Excel use that "big number crunching GPU" for anything float-related. Just getting the data to the GPU for a compute shader to run on it would take longer than just doing on the CPU in almost every case.
- bruce511 4y agoI'm not sure if the parent poster meant GPU or CPU. While yeah GPU has good floating point math, you probably don't use that for things like excel. On the other hand the CPU has floating point math too, and floating point math is MUCH faster than decimal math. So his point holds if you replace GPU with CPU, but his use of GPU is likely inaccurate.
- t8sr 4y agoAh, yeah. The performance of modern FPUs really kills, and it's changing a lot of the assumptions I used to have about performance. Anecdote: In state of the art physics code, it's common to use integers for coordinates [1]. Recently, I was working on a BSc. toy project, and I used ints for coordinates as is common. With both ints and floats it's important to be careful around functions like `tan` that go to infinity, but of course floats are more forgiving, so I prototyped some of the code using doubles. I ended up comparing performance and it wasn't even funny. Double precision arithmetic was anywhere between 3x (where a good int algorithm is known) all the way to 100x faster (if the int algorithm is cordic, for example) than integers. 1: Springel 2013 p. 1-82 https://wwwmpa.mpa-garching.mpg.de/gadget4/gadget4-code-paper.pdf https://wwwmpa.mpa-garching.mpg.de/gadget4/gadget4-code-pape...
- albrewer 4y ago> you probably don't use that for things like excel I'm not sure when I read it, but long ago I read some kind of AMA from a MS engineer working on Excel saying that his greatest achievement was working on the team that made the Excel's DAG solver trivially parallelizable. In the same thread, he mentioned that offloading to the GPU was being looked into. I guess it never came to fruition.
- Kon-Peki 4y ago> use of GPU is likely inaccurate. The number 1 supercomputer in the world has 8 million GPU cores (or is it 8 million GPUs? Execution Units?) and 600k CPU cores. They are doing floating point math on GPUs. Numerical analysis [1] is used to create the best accuracy possible. This is something that has been done for thousands of years, basically since math has had problems with no "exact" solution. [1] https://en.wikipedia.org/wiki/Numerical_analysis https://en.wikipedia.org/wiki/Numerical_analysis
- int_19h 4y agoWe should be optimizing for correctness over performance by default, though. People who need binary floating point for perf reasons should already know the tradeoffs.
- Karellen 4y agoI remember reading on a forum many years ago where one person was rationalising performance over correctness, someone replied that if their code didn't have to be correct they could get the answer in clock 1 cycle with zero memory usage. :-)