Always false float comparisons

Joakim via Digitalmars-d digitalmars-d at puremagic.com
Mon May 16 12:38:10 PDT 2016


On Saturday, 14 May 2016 at 20:38:54 UTC, Walter Bright wrote:
> On 5/14/2016 11:46 AM, Walter Bright wrote:
>> I used to design and build digital electronics out of TTL 
>> chips. Over time, TTL
>> chips got faster and faster. The rule was to design the 
>> circuit with a minimum
>> signal propagation delay, but never a maximum. Therefore, 
>> putting in faster
>> parts will never break the circuit.
>
> Eh, I got the min and max backwards.

Heh, I read that and thought, "wtf is he talking about, never a 
max?" :D

Regarding floating-point, I'll go farther than you and say that 
if an algorithm depends on lower-precision floating-point to be 
accurate, it's a bad algorithm.  Now, people can always make 
mistakes in their implementation and unwittingly depend on lower 
precision somehow, but that _should_ fail.

None of this is controversial to me: you shouldn't be comparing 
floating-point numbers with anything other than approxEqual, 
increasing precision should never bother your algorithm, and a 
higher-precision, common soft-float for CTFE will help 
cross-compiling and you'll never notice the speed hit.


More information about the Digitalmars-d mailing list