Changeset 5681
- Timestamp:
- Jan 4, 2007, 4:44:11 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ccl/level-0/l0-numbers.lisp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/level-0/l0-numbers.lisp
r5670 r5681 428 428 (if (and (eq int 0)(= dfloat 0.0d0)) 429 429 0 430 ;; Whatever we do here should have the effect 431 ;; of comparing the integer to the result of calling 432 ;; RATIONAL on the float. We could probably 433 ;; skip the call to RATIONAL in more cases, 434 ;; but at least check the obvious ones here 435 ;; (e.g. different signs) 436 (multiple-value-bind (mantissa exponent sign) 437 (integer-decode-double-float dfloat) 438 (declare (type (integer -1 1) sign) 439 (fixnum exponent)) 440 (cond ((zerop int) 441 (- sign)) 442 ((and (< int 0) (eql sign 1)) -1) 443 ((and (> int 0) (eql sign -1)) 1) 444 (t 445 ;; See RATIONAL. Can probably avoid this if 446 ;; magnitudes are clearly dissimilar. 447 (if (= sign -1) (setq mantissa (- mantissa))) 448 (let* ((rat (if (< exponent 0) 449 (/ mantissa (ash 1 (the fixnum (- exponent)))) 450 (ash mantissa exponent)))) 451 (if (< int rat) 452 -1 453 (if (eq int rat) 454 0 455 1)))))))) 430 (with-stack-double-floats ((d1 int)) 431 (locally (declare (double-float d1)) 432 (if (eq int (%truncate-double-float->fixnum d1)) 433 (cond ((< d1 dfloat) -1) 434 ((= d1 dfloat) 0) 435 (t 1)) 436 ;; Whatever we do here should have the effect 437 ;; of comparing the integer to the result of calling 438 ;; RATIONAL on the float. We could probably 439 ;; skip the call to RATIONAL in more cases, 440 ;; but at least check the obvious ones here 441 ;; (e.g. different signs) 442 (multiple-value-bind (mantissa exponent sign) 443 (integer-decode-double-float dfloat) 444 (declare (type (integer -1 1) sign) 445 (fixnum exponent)) 446 (cond ((zerop int) 447 (- sign)) 448 ((and (< int 0) (eql sign 1)) -1) 449 ((and (> int 0) (eql sign -1)) 1) 450 (t 451 ;; See RATIONAL. Can probably avoid this if 452 ;; magnitudes are clearly dissimilar. 453 (if (= sign -1) (setq mantissa (- mantissa))) 454 (let* ((rat (if (< exponent 0) 455 (/ mantissa (ash 1 (the fixnum (- exponent)))) 456 (ash mantissa exponent)))) 457 (if (< int rat) 458 -1 459 (if (eq int rat) 460 0 461 1))))))))))) 456 462 457 463 … … 461 467 (if (and (eq int 0)(= sfloat 0.0s0)) 462 468 0 463 ;; Whatever we do here should have the effect 464 ;; of comparing the integer to the result of calling 465 ;; RATIONAL on the float. We could probably 466 ;; skip the call to RATIONAL in more cases, 467 ;; but at least check the obvious ones here 468 ;; (e.g. different signs) 469 (multiple-value-bind (mantissa exponent sign) 470 (integer-decode-short-float sfloat) 471 (declare (type (integer -1 1) sign) 472 (fixnum exponent)) 473 (cond ((zerop int) 474 (- sign)) 475 ((and (< int 0) (eql sign 1)) -1) 476 ((and (> int 0) (eql sign -1)) 1) 477 (t 478 ;; See RATIONAL. Can probably avoid this if 479 ;; magnitudes are clearly dissimilar. 480 (if (= sign -1) (setq mantissa (- mantissa))) 481 (let* ((rat (if (< exponent 0) 482 (/ mantissa (ash 1 (the fixnum (- exponent)))) 483 (ash mantissa exponent)))) 484 (if (< int rat) 485 -1 486 (if (eq int rat) 487 0 488 1)))))))) 469 (#+32-bit-target ppc2::with-stack-short-floats #+32-bit-target ((s1 int)) 470 #-32-bit-target let* #-32-bit-target ((s1 (%int-to-sfloat int))) 471 (declare (short-float s1)) 472 (if (eq (%truncate-short-float->fixnum s1) int) 473 (cond ((< s1 sfloat) -1) 474 ((= s1 sfloat) 0) 475 (t 1)) 476 ;; Whatever we do here should have the effect 477 ;; of comparing the integer to the result of calling 478 ;; RATIONAL on the float. We could probably 479 ;; skip the call to RATIONAL in more cases, 480 ;; but at least check the obvious ones here 481 ;; (e.g. different signs) 482 (multiple-value-bind (mantissa exponent sign) 483 (integer-decode-short-float sfloat) 484 (declare (type (integer -1 1) sign) 485 (fixnum exponent)) 486 (cond ((zerop int) 487 (- sign)) 488 ((and (< int 0) (eql sign 1)) -1) 489 ((and (> int 0) (eql sign -1)) 1) 490 (t 491 ;; See RATIONAL. Can probably avoid this if 492 ;; magnitudes are clearly dissimilar. 493 (if (= sign -1) (setq mantissa (- mantissa))) 494 (let* ((rat (if (< exponent 0) 495 (/ mantissa (ash 1 (the fixnum (- exponent)))) 496 (ash mantissa exponent)))) 497 (if (< int rat) 498 -1 499 (if (eq int rat) 500 0 501 1)))))))))) 489 502 490 503
Note:
See TracChangeset
for help on using the changeset viewer.
