Mercurial > emacs
comparison lisp/calc/calc.el @ 62040:d9e11e28ebbb
(calcDigit-key, math-read-number, math-read-bignum): Replace
string-to-int by string-to-number.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Mon, 02 May 2005 19:45:57 +0000 |
parents | 978f66a2432a |
children | 842c8b2c2940 08185296b491 |
comparison
equal
deleted
inserted
replaced
62039:a17f83f2c421 | 62040:d9e11e28ebbb |
---|---|
2134 (insert " ")) | 2134 (insert " ")) |
2135 (insert "mod ")))) | 2135 (insert "mod ")))) |
2136 (t | 2136 (t |
2137 (insert (char-to-string last-command-char)) | 2137 (insert (char-to-string last-command-char)) |
2138 (if (or (and (calc-minibuffer-contains "[-+]?\\(.*\\+/- *\\|.*mod *\\)?\\([0-9][0-9]?\\)#[0-9a-zA-Z]*\\(:[0-9a-zA-Z]*\\(:[0-9a-zA-Z]*\\)?\\|.[0-9a-zA-Z]*\\(e[-+]?[0-9]*\\)?\\)?\\'") | 2138 (if (or (and (calc-minibuffer-contains "[-+]?\\(.*\\+/- *\\|.*mod *\\)?\\([0-9][0-9]?\\)#[0-9a-zA-Z]*\\(:[0-9a-zA-Z]*\\(:[0-9a-zA-Z]*\\)?\\|.[0-9a-zA-Z]*\\(e[-+]?[0-9]*\\)?\\)?\\'") |
2139 (let ((radix (string-to-int | 2139 (let ((radix (string-to-number |
2140 (buffer-substring | 2140 (buffer-substring |
2141 (match-beginning 2) (match-end 2))))) | 2141 (match-beginning 2) (match-end 2))))) |
2142 (and (>= radix 2) | 2142 (and (>= radix 2) |
2143 (<= radix 36) | 2143 (<= radix 36) |
2144 (or (memq last-command-char '(?# ?: ?. ?e ?+ ?-)) | 2144 (or (memq last-command-char '(?# ?: ?. ?e ?+ ?-)) |
3276 (if (and (eq calc-language 'c) | 3276 (if (and (eq calc-language 'c) |
3277 (> (length digs) 1) | 3277 (> (length digs) 1) |
3278 (eq (aref digs 0) ?0)) | 3278 (eq (aref digs 0) ?0)) |
3279 (math-read-number (concat "8#" digs)) | 3279 (math-read-number (concat "8#" digs)) |
3280 (if (<= (length digs) 6) | 3280 (if (<= (length digs) 6) |
3281 (string-to-int digs) | 3281 (string-to-number digs) |
3282 (cons 'bigpos (math-read-bignum digs)))))) | 3282 (cons 'bigpos (math-read-bignum digs)))))) |
3283 | 3283 |
3284 ;; Clean up the string if necessary | 3284 ;; Clean up the string if necessary |
3285 ((string-match "\\`\\(.*\\)[ \t\n]+\\([^\001]*\\)\\'" s) | 3285 ((string-match "\\`\\(.*\\)[ \t\n]+\\([^\001]*\\)\\'" s) |
3286 (math-read-number (concat (math-match-substring s 1) | 3286 (math-read-number (concat (math-match-substring s 1) |
3313 ((string-match "^\\(.*\\)[eE]\\([-+]?[0-9]+\\)$" s) | 3313 ((string-match "^\\(.*\\)[eE]\\([-+]?[0-9]+\\)$" s) |
3314 (let ((mant (math-match-substring s 1)) | 3314 (let ((mant (math-match-substring s 1)) |
3315 (exp (math-match-substring s 2))) | 3315 (exp (math-match-substring s 2))) |
3316 (let ((mant (if (> (length mant) 0) (math-read-number mant) 1)) | 3316 (let ((mant (if (> (length mant) 0) (math-read-number mant) 1)) |
3317 (exp (if (<= (length exp) (if (memq (aref exp 0) '(?+ ?-)) 8 7)) | 3317 (exp (if (<= (length exp) (if (memq (aref exp 0) '(?+ ?-)) 8 7)) |
3318 (string-to-int exp)))) | 3318 (string-to-number exp)))) |
3319 (and mant exp (Math-realp mant) (> exp -4000000) (< exp 4000000) | 3319 (and mant exp (Math-realp mant) (> exp -4000000) (< exp 4000000) |
3320 (let ((mant (math-float mant))) | 3320 (let ((mant (math-float mant))) |
3321 (list 'float (nth 1 mant) (+ (nth 2 mant) exp))))))) | 3321 (list 'float (nth 1 mant) (+ (nth 2 mant) exp))))))) |
3322 | 3322 |
3323 ;; Syntax error! | 3323 ;; Syntax error! |
3328 (substring s (match-beginning n) (match-end n)) | 3328 (substring s (match-beginning n) (match-end n)) |
3329 "")) | 3329 "")) |
3330 | 3330 |
3331 (defun math-read-bignum (s) ; [l X] | 3331 (defun math-read-bignum (s) ; [l X] |
3332 (if (> (length s) 3) | 3332 (if (> (length s) 3) |
3333 (cons (string-to-int (substring s -3)) | 3333 (cons (string-to-number (substring s -3)) |
3334 (math-read-bignum (substring s 0 -3))) | 3334 (math-read-bignum (substring s 0 -3))) |
3335 (list (string-to-int s)))) | 3335 (list (string-to-number s)))) |
3336 | 3336 |
3337 | 3337 |
3338 (defconst math-tex-ignore-words | 3338 (defconst math-tex-ignore-words |
3339 '( ("\\hbox") ("\\mbox") ("\\text") ("\\left") ("\\right") | 3339 '( ("\\hbox") ("\\mbox") ("\\text") ("\\left") ("\\right") |
3340 ("\\,") ("\\>") ("\\:") ("\\;") ("\\!") ("\\ ") | 3340 ("\\,") ("\\>") ("\\:") ("\\;") ("\\!") ("\\ ") |