3 ms·
I like Go’s strategy. Consts have no type and are the only thing with implicit conversion. math.Pi is defined explicitly with a whole lot of digits and the type
by inlined 7y ago
I like Go’s strategy. Consts have no type and are the only thing with implicit conversion. math.Pi is defined explicitly with a whole lot of digits and the type system can somehow do inline math on all those digits with full precision before downcasting the final result to an int, float32, float64, etc.
- rini17 7y agoI prefer Common Lisp's way, where fractions are first class citizens. Pity it is not supported directly in hardware.
- msla 7y agoI'm not convinced supporting it in hardware would make it any faster, compared to doing what we do now with fast integer arithmetic and reasonable software algorithms. Hardware only makes things faster if there's some good parallelism you can't express in software, like doing integer addition using modern hardware versus doing it the long way bit-by-bit. Here's a whole post on the issue by an actual hardware designer: https://yosefk.com/blog/its-done-in-hardware-so-its-cheap.html https://yosefk.com/blog/its-done-in-hardware-so-its-cheap.ht... Quote: To see the limitations of hardware support, let's first look at what hardware can do to speed things up. Roughly, you can really only do two things: 1. Specialization - save dispatching costs in speed and energy. 2. Parallelization - save time, but not energy, by throwing more hardware at the job.