|
Message-ID: <20141014080634.GC4874@port70.net> Date: Tue, 14 Oct 2014 10:06:35 +0200 From: Szabolcs Nagy <nsz@...t70.net> To: musl@...ts.openwall.com Subject: Re: RE???[musl ] [math] I Found math library's bug in ceil, floor, round functions, Using arm toolchains * bobodog <8192542@...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
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.