You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/09/07 07:07:49 UTC
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7025: Add check in roundx() functions for infinite or NaN cases
pkarashchenko commented on code in PR #7025:
URL: https://github.com/apache/incubator-nuttx/pull/7025#discussion_r964462138
##########
libs/libc/math/lib_round.c:
##########
@@ -34,6 +34,11 @@
#ifdef CONFIG_HAVE_DOUBLE
double round(double x)
{
+ if (isinf(x) || isnan(x))
+ {
+ return (x);
Review Comment:
```suggestion
return x;
```
##########
libs/libc/math/lib_roundl.c:
##########
@@ -34,6 +34,11 @@
#ifdef CONFIG_HAVE_LONG_DOUBLE
long double roundl(long double x)
{
+ if (isinf_l(x) || isnan(x))
+ {
+ return (x);
+ }
+
long double f = modfl(x, &x);
Review Comment:
ditto
##########
libs/libc/math/lib_round.c:
##########
@@ -34,6 +34,11 @@
#ifdef CONFIG_HAVE_DOUBLE
double round(double x)
{
+ if (isinf(x) || isnan(x))
+ {
+ return (x);
+ }
+
double f = modf(x, &x);
Review Comment:
Please separate this. Move `double f;` before `if (isinf(x) || isnan(x))` abd change here to `f = modf(x, &x);`
##########
libs/libc/math/lib_roundl.c:
##########
@@ -34,6 +34,11 @@
#ifdef CONFIG_HAVE_LONG_DOUBLE
long double roundl(long double x)
{
+ if (isinf_l(x) || isnan(x))
+ {
+ return (x);
Review Comment:
```suggestion
return x;
```
##########
libs/libc/math/lib_roundf.c:
##########
@@ -33,6 +33,11 @@
float roundf(float x)
{
+ if (isinf_f(x) || isnan(x))
+ {
+ return (x);
+ }
+
float f = modff(x, &x);
Review Comment:
ditto
##########
libs/libc/math/lib_roundf.c:
##########
@@ -33,6 +33,11 @@
float roundf(float x)
{
+ if (isinf_f(x) || isnan(x))
+ {
+ return (x);
Review Comment:
```suggestion
return x;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org