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
19f80abb
Commit
19f80abb
authored
Sep 07, 2016
by
Luís Fonseca
Committed by
Arnim Läuger
Sep 07, 2016
Browse files
Fix float math.pow when number was negative and power was odd (#1492)
parent
3109497b
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/libc/c_math.c
View file @
19f80abb
...
...
@@ -59,6 +59,7 @@ double pow(double x, double y)
{
double
frexp
(),
g
,
ldexp
(),
r
,
u1
,
u2
,
v
,
w
,
w1
,
w2
,
y1
,
y2
,
z
;
int
iw1
,
m
,
p
;
bool
flipsignal
=
false
;
if
(
y
==
0
.
0
)
return
(
1
.
0
);
...
...
@@ -67,7 +68,7 @@ double pow(double x, double y)
if
(
x
==
0
.
0
)
{
if
(
y
>
0
.
0
)
return
(
x
)
;
return
0
.
0
;
//cmemsg(FP_POWO, &y);
//return(HUGE);
}
...
...
@@ -75,6 +76,11 @@ double pow(double x, double y)
{
//cmemsg(FP_POWN, &x);
x
=
-
x
;
if
(
y
!=
(
int
)
y
)
{
// if y is fractional, then this woud result in a complex number
return
NAN
;
}
flipsignal
=
((
int
)
y
)
&
1
;
}
}
g
=
frexp
(
x
,
&
m
);
...
...
@@ -125,7 +131,8 @@ double pow(double x, double y)
p
=
16
*
m
-
iw1
;
z
=
((((((
q7
*
w2
+
q6
)
*
w2
+
q5
)
*
w2
+
q4
)
*
w2
+
q3
)
*
w2
+
q2
)
*
w2
+
q1
)
*
w2
;
z
=
a1
[
p
]
+
a1
[
p
]
*
z
;
return
(
ldexp
(
z
,
m
));
double
res
=
ldexp
(
z
,
m
);
return
flipsignal
?
-
res
:
res
;
}
#if 0
...
...
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