Mercurial > emacs
comparison lisp/calc/calc.el @ 81741:d40120fec750
(math-bignum-digit-length): Change to optimal value.
(math-read-number-simple): Remove leading 0s.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Sat, 07 Jul 2007 23:56:33 +0000 |
parents | c88370efde0d |
children | 61fb5a974af6 |
comparison
equal
deleted
inserted
replaced
81740:8c6a9f107a7e | 81741:d40120fec750 |
---|---|
2281 (calcDigit-nondigit)))) | 2281 (calcDigit-nondigit)))) |
2282 | 2282 |
2283 | 2283 |
2284 | 2284 |
2285 | 2285 |
2286 (defconst math-bignum-digit-length 3 | 2286 (defconst math-bignum-digit-length |
2287 (truncate (/ (log10 (/ most-positive-fixnum 2)) 2)) | |
2287 "The length of a \"digit\" in Calc bignums. | 2288 "The length of a \"digit\" in Calc bignums. |
2288 If a big integer is of the form (bigpos N0 N1 ...), this is the | 2289 If a big integer is of the form (bigpos N0 N1 ...), this is the |
2289 length of the allowable Emacs integers N0, N1,... | 2290 length of the allowable Emacs integers N0, N1,... |
2290 The value of 2*10^(2*MATH-BIGNUM-DIGIT-LENGTH) must be less than the | 2291 The value of 2*10^(2*MATH-BIGNUM-DIGIT-LENGTH) must be less than the |
2291 largest Emacs integer.") | 2292 largest Emacs integer.") |
3464 S is assumed to be a simple number (integer or float without an exponent) | 3465 S is assumed to be a simple number (integer or float without an exponent) |
3465 and all digits are kept, regardless of Calc's current precision." | 3466 and all digits are kept, regardless of Calc's current precision." |
3466 (cond | 3467 (cond |
3467 ;; Integer | 3468 ;; Integer |
3468 ((string-match "^[0-9]+$" s) | 3469 ((string-match "^[0-9]+$" s) |
3470 (if (string-match "^\\(0+\\)" s) | |
3471 (setq s (substring s (match-end 0)))) | |
3469 (if (<= (length s) (* 2 math-bignum-digit-length)) | 3472 (if (<= (length s) (* 2 math-bignum-digit-length)) |
3470 (string-to-number s) | 3473 (string-to-number s) |
3471 (cons 'bigpos (math-read-bignum s)))) | 3474 (cons 'bigpos (math-read-bignum s)))) |
3472 ;; Minus sign | 3475 ;; Minus sign |
3473 ((string-match "^-[0-9]+$" s) | 3476 ((string-match "^-[0-9]+$" s) |