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 2021/12/30 19:25:43 UTC

[GitHub] [incubator-nuttx] pkarashchenko opened a new pull request #5126: libc/math: fix fmod family operation

pkarashchenko opened a new pull request #5126:
URL: https://github.com/apache/incubator-nuttx/pull/5126


   ## Summary
   `fmod()` returns incorrect value. This is due to calculations are based on dividing and multiplying back fractional part, so calculation brings computation error. Rework `fmod()` functions family 
   
   ## Impact
   NuttX native math library users
   
   ## Testing
   Tested with online C compiler.
   


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



[GitHub] [incubator-nuttx] acassis commented on pull request #5126: libc/math: fix fmod family operation

Posted by GitBox <gi...@apache.org>.
acassis commented on pull request #5126:
URL: https://github.com/apache/incubator-nuttx/pull/5126#issuecomment-1003164532


   Fixes issue: https://github.com/apache/incubator-nuttx/issues/4241


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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #5126: libc/math: fix fmod family operation

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #5126:
URL: https://github.com/apache/incubator-nuttx/pull/5126#discussion_r776915721



##########
File path: libs/libc/math/lib_modff.c
##########
@@ -44,12 +44,12 @@ float modff(float x, float *iptr)
     }
   else if (fabsf(x) < 1.0F)
     {
-      *iptr = (x * 0.0F);
+      *iptr = 0.0F;
       return x;
     }
   else
     {
-      *iptr = (float)(int)x;
+      *iptr = (float)(int) x;

Review comment:
       why add space before 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



[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5126: libc/math: fix fmod family operation

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5126:
URL: https://github.com/apache/incubator-nuttx/pull/5126#discussion_r776938717



##########
File path: libs/libc/math/lib_modff.c
##########
@@ -44,12 +44,12 @@ float modff(float x, float *iptr)
     }
   else if (fabsf(x) < 1.0F)
     {
-      *iptr = (x * 0.0F);
+      *iptr = 0.0F;
       return x;
     }
   else
     {
-      *iptr = (float)(int)x;
+      *iptr = (float)(int) x;

Review comment:
       Just to keep the same style as in other variants of `modf`. I can remove spaces in other two variants instead.




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



[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5126: libc/math: fix fmod family operation

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5126:
URL: https://github.com/apache/incubator-nuttx/pull/5126#discussion_r776985078



##########
File path: libs/libc/math/lib_modff.c
##########
@@ -44,12 +44,12 @@ float modff(float x, float *iptr)
     }
   else if (fabsf(x) < 1.0F)
     {
-      *iptr = (x * 0.0F);
+      *iptr = 0.0F;
       return x;
     }
   else
     {
-      *iptr = (float)(int)x;
+      *iptr = (float)(int) x;

Review comment:
       Done




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



[GitHub] [incubator-nuttx] acassis removed a comment on pull request #5126: libc/math: fix fmod family operation

Posted by GitBox <gi...@apache.org>.
acassis removed a comment on pull request #5126:
URL: https://github.com/apache/incubator-nuttx/pull/5126#issuecomment-1003164532


   Fixes issue: https://github.com/apache/incubator-nuttx/issues/4241


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



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #5126: libc/math: fix fmod family operation

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #5126:
URL: https://github.com/apache/incubator-nuttx/pull/5126


   


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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #5126: libc/math: fix fmod family operation

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #5126:
URL: https://github.com/apache/incubator-nuttx/pull/5126#discussion_r776956651



##########
File path: libs/libc/math/lib_modff.c
##########
@@ -44,12 +44,12 @@ float modff(float x, float *iptr)
     }
   else if (fabsf(x) < 1.0F)
     {
-      *iptr = (x * 0.0F);
+      *iptr = 0.0F;
       return x;
     }
   else
     {
-      *iptr = (float)(int)x;
+      *iptr = (float)(int) x;

Review comment:
       most cast in NuttX doesn't add space after cast, so I suggest to follow this convention




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