Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
e11721eb
Commit
e11721eb
authored
Jan 26, 2015
by
HuangRui
Browse files
Support floating point.
Add PRINTF_LONG_SUPPORT to %g option.
parent
2e513a96
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/libc/c_stdio.c
View file @
e11721eb
...
@@ -273,7 +273,11 @@ static int d2a(double num, char *bf)
...
@@ -273,7 +273,11 @@ static int d2a(double num, char *bf)
fpart
=
absnum
-
(
double
)
ipart
;
fpart
=
absnum
-
(
double
)
ipart
;
// convert integer part to string
// convert integer part to string
#ifdef PRINTF_LONG_SUPPORT
len
+=
li2a
(
ipart
,
bf
);
#else
len
+=
i2a
(
ipart
,
bf
);
len
+=
i2a
(
ipart
,
bf
);
#endif
#ifndef EPSILON
#ifndef EPSILON
#define EPSILON ((double)(0.00000001))
#define EPSILON ((double)(0.00000001))
...
@@ -299,14 +303,17 @@ static int d2a(double num, char *bf)
...
@@ -299,14 +303,17 @@ static int d2a(double num, char *bf)
{
{
fpart
=
fpart
*
10
;
fpart
=
fpart
*
10
;
}
}
#ifdef PRINTF_LONG_SUPPORT
len
+=
li2a
((
int
)
fpart
,
bf
);
#else
len
+=
i2a
((
int
)
fpart
,
bf
);
len
+=
i2a
((
int
)
fpart
,
bf
);
#endif
}
}
#undef EPSILON
#undef EPSILON
if
(
num
<
0
)
if
(
num
<
0
)
{
{
len
++
;
len
++
;
}
}
return
len
;
return
len
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment