summaryrefslogtreecommitdiff
path: root/nuttx/lib
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/lib')
-rw-r--r--nuttx/lib/lib_libvsprintf.c4
-rw-r--r--nuttx/lib/lib_rand.c22
-rw-r--r--nuttx/lib/lib_rint.c8
-rw-r--r--nuttx/lib/lib_sscanf.c6
4 files changed, 21 insertions, 19 deletions
diff --git a/nuttx/lib/lib_libvsprintf.c b/nuttx/lib/lib_libvsprintf.c
index da03f7f31..2e60ffa22 100644
--- a/nuttx/lib/lib_libvsprintf.c
+++ b/nuttx/lib/lib_libvsprintf.c
@@ -807,7 +807,7 @@ int lib_vsprintf(struct lib_stream_s *obj, const char *src, va_list ap)
char tmpfmt[40];
const char *psrc;
char *pdst;
- double dbl;
+ double_t dbl;
/* Reconstruct the floating point format. */
@@ -818,7 +818,7 @@ int lib_vsprintf(struct lib_stream_s *obj, const char *src, va_list ap)
/* Extract the floating point number. */
- dbl = va_arg(ap, double);
+ dbl = va_arg(ap, double_t);
/* Then let the lib_sprintf do the work. */
diff --git a/nuttx/lib/lib_rand.c b/nuttx/lib/lib_rand.c
index 5ce708bc8..5dde2dd8c 100644
--- a/nuttx/lib/lib_rand.c
+++ b/nuttx/lib/lib_rand.c
@@ -81,11 +81,11 @@
************************************************************/
static unsigned int nrand(unsigned int nLimit);
-static double frand1(void);
+static double_t frand1(void);
#if (RND_ORDER > 1)
-static double frand2(void);
+static double_t frand2(void);
#if (RND_ORDER > 2)
-static double frand3(void);
+static double_t frand3(void);
#endif
#endif
@@ -140,7 +140,7 @@ int rand(void)
static unsigned int nrand(unsigned int nLimit)
{
unsigned long nResult;
- double fRatio;
+ double_t fRatio;
/* Loop to be sure a legal random number is generated */
do {
@@ -155,7 +155,7 @@ static unsigned int nrand(unsigned int nLimit)
#endif
/* Then, produce the return-able value */
- nResult = (unsigned long)(((double)nLimit) * fRatio);
+ nResult = (unsigned long)(((double_t)nLimit) * fRatio);
} while (nResult >= (unsigned long)nLimit);
@@ -163,7 +163,7 @@ static unsigned int nrand(unsigned int nLimit)
} /* end nrand */
-static double frand1(void)
+static double_t frand1(void)
{
unsigned long nRandInt;
@@ -172,12 +172,12 @@ static double frand1(void)
g_nRandInt1 = nRandInt;
/* Construct an floating point value in the range from 0.0 up to 1.0 */
- return ((double)nRandInt) / ((double)RND_CONSTP);
+ return ((double_t)nRandInt) / ((double_t)RND_CONSTP);
} /* end frand */
#if (RND_ORDER > 1)
-static double frand2(void)
+static double_t frand2(void)
{
unsigned long nRandInt;
@@ -188,12 +188,12 @@ static double frand2(void)
g_nRandInt1 = nRandInt;
/* Construct an floating point value in the range from 0.0 up to 1.0 */
- return ((double)nRandInt) / ((double)RND_CONSTP);
+ return ((double_t)nRandInt) / ((double_t)RND_CONSTP);
} /* end frand */
#if (RND_ORDER > 2)
-static double frand(void)
+static double_t frand(void)
{
unsigned long nRandInt;
@@ -205,7 +205,7 @@ static double frand(void)
g_nRandInt1 = nRandInt;
/* Construct an floating point value in the range from 0.0 up to 1.0 */
- return ((double)nRandInt) / ((double)RND_CONSTP);
+ return ((double_t)nRandInt) / ((double_t)RND_CONSTP);
} /* end frand */
#endif
diff --git a/nuttx/lib/lib_rint.c b/nuttx/lib/lib_rint.c
index f747eea86..73600f6bf 100644
--- a/nuttx/lib/lib_rint.c
+++ b/nuttx/lib/lib_rint.c
@@ -72,9 +72,9 @@
* Private Variables
************************************************************/
-double rint(double x)
+double_t rint(double x)
{
- double retValue;
+ double_t retValue;
/* If the current rounding mode rounds toward negative
* infinity, rint() is identical to floor(). If the current
@@ -93,7 +93,7 @@ double rint(double x)
* |rint(x)-x|=1/2, then rint(x) is even. */
long dwInteger = (long)x;
- double fRemainder = x - (double)dwInteger;
+ double_t fRemainder = x - (double_t)dwInteger;
if (x < 0.0) {
@@ -116,7 +116,7 @@ double rint(double x)
} /* end if */
} /* end else */
- retValue = (double)dwInteger;
+ retValue = (double_t)dwInteger;
#endif
return retValue;
diff --git a/nuttx/lib/lib_sscanf.c b/nuttx/lib/lib_sscanf.c
index 4f100c8ca..efd4ebcfa 100644
--- a/nuttx/lib/lib_sscanf.c
+++ b/nuttx/lib/lib_sscanf.c
@@ -286,7 +286,7 @@ int vsscanf(char *buf, const char *s, va_list ap)
{
/* strtod always returns a double */
- double dvalue = strtod(tmp, NULL);
+ double_t dvalue = strtod(tmp, NULL);
void *pv = va_arg(ap, void*);
vdbg("vsscanf: Return %f to 0x%p\n", dvalue, pv);
@@ -295,11 +295,13 @@ int vsscanf(char *buf, const char *s, va_list ap)
* float or a double.
*/
+#ifdef CONFIG_HAVE_DOUBLE
if (lflag)
{
- *((double*)pv) = dvalue;
+ *((double_t*)pv) = dvalue;
}
else
+#endif
{
*((float*)pv) = (float)dvalue;
}