From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: RE???[musl ] [math] I Found math library's bug in ceil, floor, round functions, Using arm toolchains
Date: Tue, 14 Oct 2014 10:06:35 +0200 [thread overview]
Message-ID: <20141014080634.GC4874@port70.net> (raw)
In-Reply-To: <tencent_5AACC3A475CC3D72346DE519@qq.com>
* bobodog <8192542@qq.com> [2014-10-14 14:26:01 +0800]:
> diff --git a/src/math/ceil.c b/src/math/ceil.c
> index 22dc224..8634145 100644
> --- a/src/math/ceil.c
> +++ b/src/math/ceil.c
> @@ -4,15 +4,16 @@ double ceil(double x)
> {
> union {double f; uint64_t i;} u = {x};
> int e = u.i >> 52 & 0x7ff;
> + uint64_t n = 0x1p52;
> double_t y;
>
> if (e >= 0x3ff+52 || x == 0)
> return x;
> /* y = int(x) - x, where int(x) is an integer neighbor of x */
> if (u.i >> 63)
> - y = (double)(x - 0x1p52) + 0x1p52 - x;
> + y = (double)(x - n) + n - x;
> else
> - y = (double)(x + 0x1p52) - 0x1p52 - x;
> + y = (double)(x + n) - n - x;
> /* special case because of non-nearest rounding modes */
> if (e <= 0x3ff-1) {
> FORCE_EVAL(y);???
>
> To solve this problem, must define a variate: uint64_t n = 0x1p52;
> using n to instead of 0x1p52, then all result are correctly.???
>
this is not necessary (and possibly makes things slower)
in c99 the difference must not be observable, your compiler is broken if it is
>
> The compile flags:
> MCFLAGS := -mcpu=cortex-a8 -mtune=cortex-a8 -march=armv7-a -mfpu=neon -ftree-vectorize -ffast-math -mfloat-abi=softfp???
>
never ever -ffast-math
if you use that flag all bets are off
>
> I belive, when using this flags, the bug will happen. any one tell me how to solve it. we need optimizing flags to compile musl libc.???
>
when compiling libc dont use that flag
otherwise you can use it but i strongly suggest not to,
unless you are fully aware of the consequences
next prev parent reply other threads:[~2014-10-14 8:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-14 2:17 [math] The math library have some bug for ceil,floor,round functioin, in arm mode bobodog
2014-10-14 2:42 ` Rich Felker
2014-10-14 2:51 ` 回复: [musl] [math] The math library have some bug forceil,floor,round " bobodog
2014-10-14 3:03 ` Rich Felker
2014-10-14 4:11 ` 回复: [musl] 回复: [musl ] [math] The math library have some bugforceil,floor,round " bobodog
2014-10-14 6:26 ` RE:[musl ] [math] I Found math library's bug in ceil, floor, round functions, Using arm toolchains bobodog
2014-10-14 6:43 ` [BUG][math]build musl with optimizing flags, some math functions are broken bobodog
[not found] ` <tencent_07C7708762DD414A5A757808@qq.com>
2014-10-14 15:12 ` RE:[BUG][math]build " Rich Felker
2014-10-14 15:33 ` RE???[BUG][math]build " Szabolcs Nagy
2014-10-14 8:06 ` Szabolcs Nagy [this message]
2014-10-14 3:04 ` 回复: [musl] The math library have some bug forceil,floor,round functioin, in arm mode bobodog
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=20141014080634.GC4874@port70.net \
--to=nsz@port70.net \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).