On 20 April 2016 at 06:39, Kustaa Nyholm <kustaa.nyh...@planmeca.com> wrote:
>>The compiler can still do computations using the max
>>precision fp type it has
>
> Perhaps, but depending on the hypothetical libraries and
> hypothetical algorithms and rounding rules computing
>
> at max precisions might not produce exactly same results.
>
> Don't know for sure as I'm no expert on the intricacies
> of FP but looks to me like a real possibility.

https://en.wikipedia.org/wiki/Floating_point#IEEE_754:_floating_point_in_modern_computers

Under cosmic:
float myfloat = 0.1;
if((myfloat * 10)==1) //evaluates as false since myfloat is only
approximately 0.1.
if(((float)0.1)*10==1) //evaluates as true.

No warnings.

I think a compiler ought to give warnings for equality operators on
approximations. This would be a good reminder to programmers about the
nature of floats and help catch mistakes.

I think the original question boils down to:
Is it more important to:
a) Produce code which gets as close to the mathematically correct
result of a mathematical expression as possible,
or
b) Faithfully emulate the approximations and errors of library
functions when evaluating a mathematical expression.

The correctness of the evaluation of a mathematical expression is
unambiguous and platform independent.
I prefer a mathematical expression to be evaluated with the highest
mathematical accuracy reasonable for the software, hardware and time
constraints. If a higher mathematical accuracy rendering of an
expression is possible with faster execution and smaller code size,
this seems like a good deal.

If a programmer needs a specific set of approximation behaviour even
at the expense of code size and execution time, there are other ways
to achieve this.

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to