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 2023/01/03 19:03:34 UTC

[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #7992: modify the strtof

xiaoxiang781216 commented on code in PR #7992:
URL: https://github.com/apache/nuttx/pull/7992#discussion_r1060864940


##########
libs/libc/stdlib/lib_strtod.c:
##########
@@ -67,28 +70,106 @@
 #  define __DBL_MAX_EXP__ (1024)
 #endif
 
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+#define long_double long double
+#else
+#define long_double double
+#endif
+
+#define shgetc(f) (*(f)++)
+#define shunget(f) ((f)--)
+#define ifexist(a,b) do { if ((*a) != NULL) {**(a) = (b);} } while (0)
+
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
-static inline int is_real(double x)
+/****************************************************************************
+ * Name: scanexp
+ *
+ * Description:
+ *   Gets the sum number of a string which the value of
+ *   each character between 0 and 9
+ *
+ *   flag:1 , the value of the f will be change ;0 ,not change
+ *
+ ****************************************************************************/
+
+static long long scanexp(FAR char** f , bool flag)

Review Comment:
   `long long` need process like `long double`



##########
libs/libc/stdlib/lib_strtod.c:
##########
@@ -67,28 +70,106 @@
 #  define __DBL_MAX_EXP__ (1024)
 #endif
 
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+#define long_double long double
+#else

Review Comment:
   ```
   #elif defined(CONFIG_HAVE_DOUBLE)
   #  define long_double double
   #else
   #  define long_double float
   #endif
   ```



##########
libs/libc/stdlib/lib_strtof.c:
##########
@@ -69,28 +74,108 @@
 #  define __FLT_MAX_EXP__ (128)
 #endif
 
+#ifdef CONFIG_HAVE_LONG_DOUBLE

Review Comment:
   if you convert all computation to long double, why not forward strtof to strod directly like musl?



##########
libs/libc/stdlib/lib_strtod.c:
##########
@@ -67,28 +70,106 @@
 #  define __DBL_MAX_EXP__ (1024)
 #endif
 
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+#define long_double long double
+#else
+#define long_double double
+#endif
+
+#define shgetc(f) (*(f)++)
+#define shunget(f) ((f)--)
+#define ifexist(a,b) do { if ((*a) != NULL) {**(a) = (b);} } while (0)
+
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
-static inline int is_real(double x)
+/****************************************************************************
+ * Name: scanexp
+ *
+ * Description:
+ *   Gets the sum number of a string which the value of
+ *   each character between 0 and 9
+ *
+ *   flag:1 , the value of the f will be change ;0 ,not change
+ *
+ ****************************************************************************/
+
+static long long scanexp(FAR char** f , bool flag)

Review Comment:
   remove space before `,`



##########
libs/libc/stdlib/lib_strtod.c:
##########
@@ -67,28 +70,106 @@
 #  define __DBL_MAX_EXP__ (1024)
 #endif
 
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+#define long_double long double

Review Comment:
   ```suggestion
   #  define long_double long double
   ```



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