/[emacs]/emacs/lisp/calc/calc-frac.el
ViewVC logotype

Diff of /emacs/lisp/calc/calc-frac.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by walters, Wed Nov 14 09:04:13 2001 UTC revision 1.3 by walters, Mon Nov 19 07:33:48 2001 UTC
# Line 1  Line 1 
1  ;; Calculator for GNU Emacs, part II [calc-frac.el]  ;;; calc-frac.el --- fraction functions for Calc
2    
3  ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.  ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
 ;; Written by Dave Gillespie, daveg@synaptics.com.  
4    
5  ;; This file is part of GNU Emacs.  ;; Author: David Gillespie <daveg@synaptics.com>
6    ;; Maintainer: Colin Walters <walters@debian.org>
7    
8  ;; GNU Emacs is distributed in the hope that it will be useful,  ;; GNU Emacs is distributed in the hope that it will be useful,
9  ;; but WITHOUT ANY WARRANTY.  No author or distributor  ;; but WITHOUT ANY WARRANTY.  No author or distributor
# Line 19  Line 20 
20  ;; file named COPYING.  Among other things, the copyright notice  ;; file named COPYING.  Among other things, the copyright notice
21  ;; and this notice must be preserved on all copies.  ;; and this notice must be preserved on all copies.
22    
23    ;;; Commentary:
24    
25    ;;; Code:
26    
27  ;; This file is autoloaded from calc-ext.el.  ;; This file is autoloaded from calc-ext.el.
28  (require 'calc-ext)  (require 'calc-ext)
# Line 28  Line 31 
31    
32  (defun calc-Need-calc-frac () nil)  (defun calc-Need-calc-frac () nil)
33    
   
34  (defun calc-fdiv (arg)  (defun calc-fdiv (arg)
35    (interactive "P")    (interactive "P")
36    (calc-slow-wrapper    (calc-slow-wrapper
# Line 49  Line 51 
51    
52    
53  (defun calc-over-notation (fmt)  (defun calc-over-notation (fmt)
54    (interactive "sFraction separator (:, ::, /, //, :/): ")    (interactive
55       (list
56        (completing-read "Fraction separator: " (mapcar (lambda (s)
57                                                          (cons s 0))
58                                                        '(":" "::" "/" "//" ":/"))
59                         nil t)))
60    (calc-wrapper    (calc-wrapper
61     (if (string-match "\\`\\([^ 0-9][^ 0-9]?\\)[0-9]*\\'" fmt)     (if (string-match "\\`\\([^ 0-9][^ 0-9]?\\)[0-9]*\\'" fmt)
62         (let ((n nil))         (let ((n nil))
# Line 58  Line 65 
65                     fmt (math-match-substring fmt 1)))                     fmt (math-match-substring fmt 1)))
66           (if (eq n 0) (error "Bad denominator"))           (if (eq n 0) (error "Bad denominator"))
67           (calc-change-mode 'calc-frac-format (list fmt n) t))           (calc-change-mode 'calc-frac-format (list fmt n) t))
68       (error "Bad fraction separator format."))))       (error "Bad fraction separator format"))))
69    
70  (defun calc-slash-notation (n)  (defun calc-slash-notation (n)
71    (interactive "P")    (interactive "P")
# Line 71  Line 78 
78    (calc-wrapper    (calc-wrapper
79     (calc-change-mode 'calc-prefer-frac n nil t)     (calc-change-mode 'calc-prefer-frac n nil t)
80     (message (if calc-prefer-frac     (message (if calc-prefer-frac
81                  "Integer division will now generate fractions."                  "Integer division will now generate fractions"
82                "Integer division will now generate floating-point results."))))                "Integer division will now generate floating-point results"))))
   
   
   
83    
84    
85  ;;;; Fractions.  ;;;; Fractions.
# Line 130  Line 134 
134                      (nth 1 b))))                      (nth 1 b))))
135    
136    
   
   
137  ;;; Convert a real value to fractional form.  [T R I; T R F] [Public]  ;;; Convert a real value to fractional form.  [T R I; T R F] [Public]
138  (defun calcFunc-frac (a &optional tol)  (defun calcFunc-frac (a &optional tol)
139    (or tol (setq tol 0))    (or tol (setq tol 0))

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26