hartmannathan commented on code in PR #7850:
URL: https://github.com/apache/nuttx/pull/7850#discussion_r1047669199


##########
libs/libc/math/lib_scalbnf.c:
##########
@@ -0,0 +1,76 @@
+/****************************************************************************
+ * libs/libc/math/lib_scalbnf.c
+ * get a double number of x*2^n
+ *
+ * This file is a part of NuttX:
+ *
+ *   Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ *   Ported by: Darcy Gong
+ *
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <math.h>
+#include <stdint.h>
+
+#define FLT_MIN 0x1p-126f
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: scalbnf
+ *
+ * Description:
+ *   get a float number of x*2^n
+ *
+ ****************************************************************************/
+
+float scalbnf(float x, int n)
+{
+  union
+    {
+      float f;
+      uint32_t i;
+    }u;
+
+  float_t y = x;
+
+  if (n > 127)
+    {
+      y *= 0x1p127f;
+      n -= 127;
+      if (n > 127)
+        {
+          y *= 0x1p127f;
+          n -= 127;
+          if (n > 127)
+            {
+              n = 127;
+            }
+        }
+    }
+  else if (n < -126)
+    {
+      y *= FLT_MIN * 0x1p24f;
+      n += 126 - 24;
+      if (n < -126)
+        {
+          y *= FLT_MIN * 0x1p24f;

Review Comment:
   Same note as above.



##########
libs/libc/math/lib_scalbnf.c:
##########
@@ -0,0 +1,76 @@
+/****************************************************************************
+ * libs/libc/math/lib_scalbnf.c
+ * get a double number of x*2^n
+ *
+ * This file is a part of NuttX:
+ *
+ *   Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ *   Ported by: Darcy Gong
+ *
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <math.h>
+#include <stdint.h>
+
+#define FLT_MIN 0x1p-126f
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: scalbnf
+ *
+ * Description:
+ *   get a float number of x*2^n
+ *
+ ****************************************************************************/
+
+float scalbnf(float x, int n)
+{
+  union
+    {
+      float f;
+      uint32_t i;
+    }u;
+
+  float_t y = x;
+
+  if (n > 127)
+    {
+      y *= 0x1p127f;
+      n -= 127;
+      if (n > 127)
+        {
+          y *= 0x1p127f;
+          n -= 127;
+          if (n > 127)
+            {
+              n = 127;
+            }
+        }
+    }
+  else if (n < -126)
+    {
+      y *= FLT_MIN * 0x1p24f;

Review Comment:
   Note that if the above suggestion is not committed, this reads as:
   
   y *= 0x1p - (126f * 0x1p24f);
   
   but if the above suggestion is committed, this reads as:
   
   y *= (0x1p - 126f) * 0x1p24f;
   
   tl;dr: Committing the above suggestion will change the outcome here. Is 
there a mistake somewhere?



##########
libs/libc/math/lib_scalbnf.c:
##########
@@ -0,0 +1,76 @@
+/****************************************************************************
+ * libs/libc/math/lib_scalbnf.c
+ * get a double number of x*2^n
+ *
+ * This file is a part of NuttX:
+ *
+ *   Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ *   Ported by: Darcy Gong
+ *
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <math.h>
+#include <stdint.h>
+
+#define FLT_MIN 0x1p-126f

Review Comment:
   ```suggestion
   #define FLT_MIN (0x1p-126f)
   ```
   



-- 
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-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to