April 20, 2013
On 04/20/2013 11:04 AM, "Casper Færgemand" <shorttail@gmail.com>" wrote:

> The D book has a diagram that shows implicit conversions.

It is Figure 2.3 on page 44 of my copy of TDPL.

> All implicit
> conversions from integral types to floating point go to real, not double
> or float.

Yes. The figure shows that implicit conversions are possible between float<-->double and double<-->real (in both directions). It indicates that float<-->real is possible as well.

Ali

April 28, 2013
Am Mon, 15 Apr 2013 11:51:43 -0400
schrieb "Steven Schveighoffer" <schveiguy@yahoo.com>:

> On Mon, 15 Apr 2013 11:51:07 -0400, Steven Schveighoffer <schveiguy@yahoo.com> wrote:
> 
> > I would suspect that the issue is floating point error.  On certain hardware, the CPU uses higher-precision 80-bit floating points.  When you store those back to doubles, the extra precision is truncated.
> 
> I see you use float not double, but the point is still valid.
> 
> -Steve

What worries me is that this jeopardizes the efforts put into
C to make floating point calculations the same under all
circumstances. GCC for example has the fast-math switch if you
really want just the fastest way to get a result, but
otherwise follows strict evaluation and assignment order of
floating point math even in const-folding, so situations like
these don't occur.
I completely agree with your explanation why it happens and I
think it is a bug that must be reported to the respective
compiler developers.

-- 
Marco

April 28, 2013
On 04/28/2013 12:39 PM, Marco Leise wrote:

> What worries me is that this jeopardizes the efforts put into
> C to make floating point calculations the same under all
> circumstances.

That is news to me. I remember knowing this problem from C. Perhaps something new in the C standard that I haven't been following?

> GCC for example has the fast-math switch if you
> really want just the fastest way to get a result, but
> otherwise follows strict evaluation and assignment order of
> floating point math even in const-folding, so situations like
> these don't occur.

That may be gcc's attempt at bringing sanity to this aspect of C.

Ali

1 2
Next ›   Last »