Mercurial > emacs
comparison lisp/calc/calc-bin.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 0d8b17d428b5 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; calc-bin.el --- binary functions for Calc | 1 ;;; calc-bin.el --- binary functions for Calc |
2 | 2 |
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, |
4 ;; 2005 Free Software Foundation, Inc. | |
4 | 5 |
5 ;; Author: David Gillespie <daveg@synaptics.com> | 6 ;; Author: David Gillespie <daveg@synaptics.com> |
6 ;; Maintainers: D. Goel <deego@gnufans.org> | 7 ;; Maintainer: Jay Belanger <belanger@truman.edu> |
7 ;; Colin Walters <walters@debian.org> | |
8 | 8 |
9 ;; This file is part of GNU Emacs. | 9 ;; This file is part of GNU Emacs. |
10 | 10 |
11 ;; GNU Emacs is distributed in the hope that it will be useful, | 11 ;; GNU Emacs is distributed in the hope that it will be useful, |
12 ;; but WITHOUT ANY WARRANTY. No author or distributor | 12 ;; but WITHOUT ANY WARRANTY. No author or distributor |
26 ;;; Commentary: | 26 ;;; Commentary: |
27 | 27 |
28 ;;; Code: | 28 ;;; Code: |
29 | 29 |
30 ;; This file is autoloaded from calc-ext.el. | 30 ;; This file is autoloaded from calc-ext.el. |
31 | |
31 (require 'calc-ext) | 32 (require 'calc-ext) |
32 | |
33 (require 'calc-macs) | 33 (require 'calc-macs) |
34 | |
35 (defun calc-Need-calc-bin () nil) | |
36 | |
37 | 34 |
38 ;;; b-prefix binary commands. | 35 ;;; b-prefix binary commands. |
39 | 36 |
40 (defun calc-and (n) | 37 (defun calc-and (n) |
41 (interactive "P") | 38 (interactive "P") |
137 calc-word-size)))) | 134 calc-word-size)))) |
138 (setq n (if (stringp n) | 135 (setq n (if (stringp n) |
139 (if (equal n "") | 136 (if (equal n "") |
140 calc-word-size | 137 calc-word-size |
141 (if (string-match "\\`[-+]?[0-9]+\\'" n) | 138 (if (string-match "\\`[-+]?[0-9]+\\'" n) |
142 (string-to-int n) | 139 (string-to-number n) |
143 (error "Expected an integer"))) | 140 (error "Expected an integer"))) |
144 (prefix-numeric-value n))) | 141 (prefix-numeric-value n))) |
145 (or (= n calc-word-size) | 142 (or (= n calc-word-size) |
146 (if (> (math-abs n) 100) | 143 (if (> (math-abs n) 100) |
147 (calc-change-mode 'calc-word-size n calc-leading-zeros) | 144 (calc-change-mode 'calc-word-size n calc-leading-zeros) |
654 | 651 |
655 (defun math-format-radix-float (a prec) | 652 (defun math-format-radix-float (a prec) |
656 (let ((fmt (car calc-float-format)) | 653 (let ((fmt (car calc-float-format)) |
657 (figs (nth 1 calc-float-format)) | 654 (figs (nth 1 calc-float-format)) |
658 (point calc-point-char) | 655 (point calc-point-char) |
659 (str nil)) | 656 (str nil) |
657 pos) | |
660 (if (eq fmt 'fix) | 658 (if (eq fmt 'fix) |
661 (let* ((afigs (math-abs figs)) | 659 (let* ((afigs (math-abs figs)) |
662 (fp (math-float-parts a (> afigs 0))) | 660 (fp (math-float-parts a (> afigs 0))) |
663 (calc-internal-prec (+ 3 (max (nth 2 fp) | 661 (calc-internal-prec (+ 3 (max (nth 2 fp) |
664 (math-convert-radix-digits | 662 (math-convert-radix-digits |
749 (when calc-group-digits | 747 (when calc-group-digits |
750 (setq str (math-group-float str))) | 748 (setq str (math-group-float str))) |
751 (if explo | 749 (if explo |
752 (let ((estr (let ((calc-number-radix 10) | 750 (let ((estr (let ((calc-number-radix 10) |
753 (calc-group-digits nil)) | 751 (calc-group-digits nil)) |
754 (setq estr (math-format-number | 752 (math-format-number |
755 (math-sub explo eadj)))))) | 753 (math-sub explo eadj))))) |
756 (setq str (if (or (memq calc-language '(math maple)) | 754 (setq str (if (or (memq calc-language '(math maple)) |
757 (> calc-number-radix 14)) | 755 (> calc-number-radix 14)) |
758 (format "%s*%d.^%s" str calc-number-radix estr) | 756 (format "%s*%d.^%s" str calc-number-radix estr) |
759 (format "%se%s" str estr))))))) | 757 (format "%se%s" str estr))))))) |
760 str)) | 758 str)) |
772 (math-mul n log) | 770 (math-mul n log) |
773 (math-div n log)))) | 771 (math-div n log)))) |
774 math-radix-digits-cache)))))))) | 772 math-radix-digits-cache)))))))) |
775 | 773 |
776 (defvar math-radix-float-cache-tag nil) | 774 (defvar math-radix-float-cache-tag nil) |
775 (defvar math-radix-float-cache) | |
777 | 776 |
778 (defun math-radix-float-power (n) | 777 (defun math-radix-float-power (n) |
779 (if (eq n 0) | 778 (if (eq n 0) |
780 '(float 1 0) | 779 '(float 1 0) |
781 (or (and (eq calc-number-radix (car math-radix-float-cache-tag)) | 780 (or (and (eq calc-number-radix (car math-radix-float-cache-tag)) |
801 '(float 1 0) | 800 '(float 1 0) |
802 (math-float | 801 (math-float |
803 calc-number-radix)))))) | 802 calc-number-radix)))))) |
804 math-radix-float-cache)))))))) | 803 math-radix-float-cache)))))))) |
805 | 804 |
806 | 805 (provide 'calc-bin) |
806 | |
807 ;;; arch-tag: f6dba7bc-53b2-41ae-919c-c266ab0ca8b3 | |
807 ;;; calc-bin.el ends here | 808 ;;; calc-bin.el ends here |