public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97086] New: aix: ceilf and truncf do not preserve the sign bit when output is rounded to 0
@ 2020-09-17 13:01 mfarazma.ext at gmail dot com
  2020-09-17 16:32 ` [Bug target/97086] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mfarazma.ext at gmail dot com @ 2020-09-17 13:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97086

            Bug ID: 97086
           Summary: aix: ceilf and truncf do not preserve the sign bit
                    when output is rounded to 0
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mfarazma.ext at gmail dot com
  Target Milestone: ---

Test program:

#include <iostream>
#include <math.h>

int main(){
         float input = -0.1;
         printf("%f\n", ceilf(-0.1));  // -0.000000 , correct
         printf("%f\n", ceilf(input)); // 0.000000  , wrong
  return 0;
}

Compile with:
g++ test.cc
./a.out

"ceilf" does not preserve the sign bit when its input is passed by value and
the output is rounded to 0.

The same happens when using "truncf".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/97086] aix: ceilf and truncf do not preserve the sign bit when output is rounded to 0
  2020-09-17 13:01 [Bug c++/97086] New: aix: ceilf and truncf do not preserve the sign bit when output is rounded to 0 mfarazma.ext at gmail dot com
@ 2020-09-17 16:32 ` pinskia at gcc dot gnu.org
  2020-10-13 15:30 ` mfarazma.ext at gmail dot com
  2020-10-13 15:39 ` mfarazma.ext at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-09-17 16:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97086

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |target

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This might NOT be a GCC issue but rather an issue with the libc that AIX has.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/97086] aix: ceilf and truncf do not preserve the sign bit when output is rounded to 0
  2020-09-17 13:01 [Bug c++/97086] New: aix: ceilf and truncf do not preserve the sign bit when output is rounded to 0 mfarazma.ext at gmail dot com
  2020-09-17 16:32 ` [Bug target/97086] " pinskia at gcc dot gnu.org
@ 2020-10-13 15:30 ` mfarazma.ext at gmail dot com
  2020-10-13 15:39 ` mfarazma.ext at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: mfarazma.ext at gmail dot com @ 2020-10-13 15:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97086

--- Comment #2 from m farazma <mfarazma.ext at gmail dot com> ---
Wanted to point out the same happens when using "nearbyint":
```
#include <iostream>
#include <math.h>

int main(){
 std::cout << nearbyintf(-0) << std::endl;
 return 0;
}
```
expected: -0
actual: 0

https://en.cppreference.com/w/c/numeric/math/nearbyint
Above url clearly mentions "If arg is ±0, it is returned, unmodified".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/97086] aix: ceilf and truncf do not preserve the sign bit when output is rounded to 0
  2020-09-17 13:01 [Bug c++/97086] New: aix: ceilf and truncf do not preserve the sign bit when output is rounded to 0 mfarazma.ext at gmail dot com
  2020-09-17 16:32 ` [Bug target/97086] " pinskia at gcc dot gnu.org
  2020-10-13 15:30 ` mfarazma.ext at gmail dot com
@ 2020-10-13 15:39 ` mfarazma.ext at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: mfarazma.ext at gmail dot com @ 2020-10-13 15:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97086

--- Comment #3 from m farazma <mfarazma.ext at gmail dot com> ---
Sorry the above example needs to be changed to this in order to reproduce the
bug:

```
#include <iostream>
#include <math.h>

int main(){
 float a = -0.0;
 std::cout << nearbyintf(a) << std::endl;
 return 0;
}
```

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-13 15:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 13:01 [Bug c++/97086] New: aix: ceilf and truncf do not preserve the sign bit when output is rounded to 0 mfarazma.ext at gmail dot com
2020-09-17 16:32 ` [Bug target/97086] " pinskia at gcc dot gnu.org
2020-10-13 15:30 ` mfarazma.ext at gmail dot com
2020-10-13 15:39 ` mfarazma.ext at gmail dot com

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).