Always false float comparisons

Manu via Digitalmars-d digitalmars-d at puremagic.com
Wed May 18 04:27:45 PDT 2016


On 18 May 2016 at 18:21, Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On 5/18/2016 12:56 AM, Ethan Watson wrote:
>>
>> > In any case, the problem Manu was having was with C++.
>> VU code was all assembly, I don't believe there was a C/C++ compiler for
>> it.
>
>
> The constant folding part was where, then?

The comparison was a 24bit fpu doing runtime work but where some
constant input data was calculated with a separate 32bit fpu. The
particulars were not ever intended to be relevant to the conversation,
except the fact that 2 differently precisioned float units were
producing output that then had to reconcile.

The analogy was to CTFE doing all its work at 80bits, and then the
processor doing work with the types explicitly stated by the
programmer; a runtime calculation compared against the same compile
time calculate is likely to be quite radically different. I don't care
about the precision, I just care that they're really different.
Ideally, CTFE would produce a result that is as similar to the runtime
result as reasonably possible, and I expect using the stated types to
do the calculations would get much much closer.
I don't know if a couple of least-significant bits of difference would
have caused problems for us, I suspect not, but I know that doing math
at radically different precisions (ie, 32bits vs 80bits) does lead to
radically different results, not just a couple of bits. That is my
concern wrt reproduction of my anecdote from PS2 and Gamecubes 24bit
fpu's.


More information about the Digitalmars-d mailing list