On Tue, 7 May 2024 at 17:39, Jonathan Wakely <jwakely....@gmail.com> wrote:
>
> On Tue, 7 May 2024 at 17:33, Jeff Law wrote:
> >
> >
> >
> > On 5/7/24 9:36 AM, Andreas Schwab wrote:
> > > On Mai 07 2024, Jonathan Wakely wrote:
> > >
> > >> +#ifdef __riscv
> > >> +    return _M_insert(__builtin_copysign((double)__f,
> > >> +                                        
> > >> (double)-__builtin_signbit(__f));
> > >
> > > Should this use static_cast<double>?
>
> Meh. It wouldn't fit in 80 columns any more with static_cast, and it
> means exactly the same thing.
>
> > And it's missing a close paren.
>
> Now that's more important! Thanks.

Also, I've just realised that signbit might return a negative value if
the signbit is set. The spec only says it returns non-zero if the
signbit is set.

So maybe we want:

#ifdef __riscv
        const int __neg = __builtin_signbit(__f) ? -1 : 0;
        return _M_insert(__builtin_copysign(static_cast<double>(__f),
                                              static_cast<double>(__neg)));
#else
        return _M_insert(static_cast<double>(__f));
#endif

Reply via email to