From: Craig Howland <howland@LGSInnovations.com>
To: <newlib@sourceware.org>
Subject: Re: [PATCH] Don't call double rint from float powf.
Date: Tue, 12 Dec 2017 19:00:00 -0000 [thread overview]
Message-ID: <e65cf74b-95fc-0f55-cd24-eeea2a7c3c3f@LGSInnovations.com> (raw)
In-Reply-To: <9d879f6e-c2c5-00e4-5552-340a36b6d3b8@sifive.com>
On 12/12/2017 01:00 PM, Jim Wilson wrote:
> On 12/11/2017 04:37 PM, Craig Howland wrote:
>> On 12/11/2017 07:08 PM, Jim Wilson wrote:
>>> - if(x<0.0&&rint(y)!=y) exc.retval = -HUGE_VAL;
>>> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â if(x<0.0&&rintf(y)!=y) exc.retval = -HUGE_VAL;
>>> Â Â Â Â Â Â Â Â Â Â Â Â Â }
>>> Â Â Â Â Â Â Â Â Â Â Â Â Â if (_LIB_VERSION == _POSIX_)
>>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â errno = ERANGE;
>> To be most rigorous, "0.0" on the same lines as the rintf() should be "0.0F"
>> (as otherwise the comparison strictly should be done in double). (Not
>> addressing the exact change you are making, but is the same class of fix and
>> are on the same line of source code.)
>
> Any reasonable compiler will get this right. GCC does a float compare here
> even if you compile without optimization. So no fix here is required, though
> I can redo the patch if you want.
>
If you don't mind, it would be best that way, as it keeps the source compliant
with the C standard in terms of requiring a float comparison. But it also could
be cleaned up later on, as I expect that there are some others that are the same
way that could also use it.
(It is an interesting thing to consider to decide if GCC is doing the right
thing here, or not. While it knows that it is comparing against 0 and that
converting it from double 0 to float 0 has no runtime side effects, the user
could have purposely done it this way because they wanted to avoid a float
comparison. I do agree that making it a float comparison is a good choice, just
that it could potentially be considered to be not in compliance with the standard.)
next prev parent reply other threads:[~2017-12-12 18:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-12 0:14 Jim Wilson
2017-12-12 3:45 ` Craig Howland
2017-12-12 12:49 ` Corinna Vinschen
2017-12-12 18:14 ` Jim Wilson
2017-12-12 18:05 ` Jim Wilson
2017-12-12 19:00 ` Craig Howland [this message]
2017-12-12 19:39 ` [PATCH v2] " Jim Wilson
2017-12-13 10:35 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e65cf74b-95fc-0f55-cd24-eeea2a7c3c3f@LGSInnovations.com \
--to=howland@lgsinnovations.com \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).