Mercurial > emacs
comparison src/floatfns.c @ 3673:8ab0a7453577
(Fexpt): New local `val' for making integer to return.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 12 Jun 1993 07:19:24 +0000 |
parents | 507f64624555 |
children | 9352d7d021c2 |
comparison
equal
deleted
inserted
replaced
3672:3eaec128c91e | 3673:8ab0a7453577 |
---|---|
404 CHECK_NUMBER_OR_FLOAT (arg2, 0); | 404 CHECK_NUMBER_OR_FLOAT (arg2, 0); |
405 if ((XTYPE (arg1) == Lisp_Int) && /* common lisp spec */ | 405 if ((XTYPE (arg1) == Lisp_Int) && /* common lisp spec */ |
406 (XTYPE (arg2) == Lisp_Int)) /* don't promote, if both are ints */ | 406 (XTYPE (arg2) == Lisp_Int)) /* don't promote, if both are ints */ |
407 { /* this can be improved by pre-calculating */ | 407 { /* this can be improved by pre-calculating */ |
408 int acc, x, y; /* some binary powers of x then accumulating */ | 408 int acc, x, y; /* some binary powers of x then accumulating */ |
409 /* these, thereby saving some time. -wsr */ | 409 Lisp_Object val; |
410 | |
410 x = XINT (arg1); | 411 x = XINT (arg1); |
411 y = XINT (arg2); | 412 y = XINT (arg2); |
412 acc = 1; | 413 acc = 1; |
413 | 414 |
414 if (y < 0) | 415 if (y < 0) |
429 acc *= x; | 430 acc *= x; |
430 x *= x; | 431 x *= x; |
431 y = (unsigned)y >> 1; | 432 y = (unsigned)y >> 1; |
432 } | 433 } |
433 } | 434 } |
434 XSET (x, Lisp_Int, acc); | 435 XSET (val, Lisp_Int, acc); |
435 return x; | 436 return val; |
436 } | 437 } |
437 f1 = (XTYPE (arg1) == Lisp_Float) ? XFLOAT (arg1)->data : XINT (arg1); | 438 f1 = (XTYPE (arg1) == Lisp_Float) ? XFLOAT (arg1)->data : XINT (arg1); |
438 f2 = (XTYPE (arg2) == Lisp_Float) ? XFLOAT (arg2)->data : XINT (arg2); | 439 f2 = (XTYPE (arg2) == Lisp_Float) ? XFLOAT (arg2)->data : XINT (arg2); |
439 /* Really should check for overflow, too */ | 440 /* Really should check for overflow, too */ |
440 if (f1 == 0.0 && f2 == 0.0) | 441 if (f1 == 0.0 && f2 == 0.0) |