3 ms·
Ooh thanks that’s horrible :-) Yes I need to investigate that in more detail. Edited to add: one option for making my assumption true might be to use fmul_fas
by fanf2 6y ago
Ooh thanks that’s horrible :-)
Yes I need to investigate that in more detail.
Edited to add: one option for making my assumption true might be to use fmul_fast and friends https://doc.rust-lang.org/core/intrinsics/fn.fmul_fast.html https://doc.rust-lang.org/core/intrinsics/fn.fmul_fast.html
- frazar0 6y agoAn alternative could be to create another zero-sized type for NaN and Infinity
- fanf2 6y agoYeah I have been thinking about something like that, but we don’t know at compile time when NaN will turn up. (I suppose if you take abstract interpretation as far as you can, you get to partial evaluation, but I am not in that game!) Another idea is to rely on Rust-specific optimizations: make the concrete type used by the result expressions into enum ZeroNum { Zero, Num(f64), } Operator overloading on this type works like it does on the separate Zero and Num types, but the cases are tested at run time instead of compile time. But this type is only used in a small context where the optimizer should be able to eliminate the checks in the same way I naively thought it would do for ops with 0.0.
- BoiledCabbage 6y agoIt's incredible the "right" response to OPs comment isn't "for all the great benefits we've had, we've also really f'ed up programing along the way". Instead it's "yes it's my fault that I forgot about the nonsensical concepts of positive and negative zero, and that the associative operation of addition isn't actually associative, and that addition's identity isn't actually and identity..." Scheme has Numerical towers that automatically abstract over exact numeric representations, but instead this clearly smart engine is forced to spend mental cycles remembering and debugging this arbitrary special case logic. Nulls, floating point, ... we really have some huge programming mistakes that have cost so much time over the years. An no this isn't a rant on 'everybody should use scheme or Lisp, because that completely misses the point. It's that 'Worse Is Better' really is worse in the long run.