lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] MinGW-w64 anomaly?


From: Greg Chicares
Subject: Re: [lmi] MinGW-w64 anomaly?
Date: Tue, 20 Dec 2016 02:41:20 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0

On 2016-12-19 00:38, Vadim Zeitlin wrote:
> On Sun, 18 Dec 2016 22:18:07 +0000 Greg Chicares <address@hidden> wrote:
[...]
> GC> Yet I really do want long doubles.
> 
>  This is the part which worries me because it means that either lmi will
> need to continue to use x87 forever or will need to using something
> non-standard like __float128. Shouldn't 52 bits of precision be enough for,
> well, basically anything?

Extended precision does have its advantages, of course, and the x87
stuff is still in hardware, so why not use it where appropriate?
Here, given DBL input, we're doing
  rint(LDBL * LDBL) / LDBL
and then casting the result once and only once, upon return, with
no intermediate stores; isn't this the sort of use case for which
extended precision was invented?

> GC> This discussion leads me to think that instead of hoping for std::pow()
> GC> to do exactly what I want, I might try [untested sketch]:
> GC> 
> GC> long double lmi_powli(long double base, int iexp)
> GC> {
> GC>     if(i < 0)
> GC>       return 1.0L / lmi_powli(base, -iexp);
> GC>     else
> GC>       return std::pow(base, iexp);
> GC> }
> GC> 
> GC> Then, when 'base' has an exact integer value, a standard-conforming
> GC> implementation is at least highly likely to do what I want.
> 
>  Yes, I agree, this should indeed fulfill your requirements.

Committed ae22927..83d8eb3 . Please let me know if you find any
contemporary compiler that doesn't pass the round_to unit test.
Having committed this, I'm not sure it's really preferable to
the code between #if 0 ... #endif, especially if the newer code
works with fewer compilers.

> GC> It's probably time to reveal my motivation, which is to modernize and
> GC> simplify 'round_to.hpp'. I didn't want to state that earlier because
> GC> that file will soon become smaller and much clearer.
> 
>  I'm definitely looking forward to it, this is not a part of lmi I really
> like delving into right now.

After this:
 round_to.hpp      | 331 +++++++++++++++---------------------------------------
 round_to_test.cpp |   6 +-
 2 files changed, 92 insertions(+), 245 deletions(-)
I'd say it's rather less rusty.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]