Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
4ed0cebd
Commit
4ed0cebd
authored
May 03, 2011
by
Paul Eggert
Browse files
* floatfns.c (Fexpt): Likewise.
parent
7fc4768c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
17 deletions
+30
-17
src/ChangeLog
src/ChangeLog
+1
-0
src/floatfns.c
src/floatfns.c
+29
-17
No files found.
src/ChangeLog
View file @
4ed0cebd
...
...
@@ -7,6 +7,7 @@
(arith_driver, Fadd1, Fsub1): Use floating point if the result is
out of Emacs fixnum range.
* bytecode.c (exec_byte_code): Likewise, for Bsub1, Badd1, Bnegate.
* floatfns.c (Fexpt): Likewise.
* callproc.c (Fcall_process): Use 'volatile' to avoid vfork clobbering.
...
...
src/floatfns.c
View file @
4ed0cebd
...
...
@@ -491,27 +491,39 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
y
=
XINT
(
arg2
);
acc
=
1
;
if
(
y
<
0
)
{
if
(
x
==
1
)
acc
=
1
;
else
if
(
x
==
-
1
)
acc
=
(
y
&
1
)
?
-
1
:
1
;
else
acc
=
0
;
}
else
if
((
x
==
0
&&
y
!=
0
)
||
x
==
1
||
(
x
==
-
1
&&
(
y
&
1
)))
return
arg1
;
if
(
x
==
-
1
)
y
=
0
;
while
(
1
)
{
while
(
y
>
0
)
if
(
y
&
1
)
{
if
(
y
&
1
)
acc
*=
x
;
x
*=
x
;
y
=
(
unsigned
)
y
>>
1
;
if
(
x
<
0
?
(
acc
<
0
?
acc
<
MOST_POSITIVE_FIXNUM
/
x
:
MOST_NEGATIVE_FIXNUM
/
x
<
acc
)
:
(
acc
<
0
?
acc
<
MOST_NEGATIVE_FIXNUM
/
x
:
MOST_POSITIVE_FIXNUM
/
x
<
acc
))
break
;
acc
*=
x
;
}
y
>>=
1
;
if
(
y
==
0
)
{
XSETINT
(
val
,
acc
);
return
val
;
}
if
(
x
<
0
?
x
<
MOST_POSITIVE_FIXNUM
/
x
:
MOST_POSITIVE_FIXNUM
/
x
<
x
)
break
;
x
*=
x
;
}
XSETINT
(
val
,
acc
);
return
val
;
}
f1
=
FLOATP
(
arg1
)
?
XFLOAT_DATA
(
arg1
)
:
XINT
(
arg1
);
f2
=
FLOATP
(
arg2
)
?
XFLOAT_DATA
(
arg2
)
:
XINT
(
arg2
);
...
...
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