[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange bug

From: Deepak Goel
Subject: Re: Strange bug
Date: 20 Jan 2001 22:09:45 -0500

> Allow me to change my "bug report" to a query: Is there a bignum package 
> for emacs that supercedes all the regular operators so the if I add a 
> bunch of prices, I don't get strange numbers?

Try this: (i use this for dealing with money, and bind this to C-c s )
(s for sexp..)

PS: another thing i find frustrating is emacs's (/ 5 2) ==> 2, whereas
i want 2.5.. so u might also find useful the // i am attaching..

(defun eval-last-sexp-my (internal-arg)
  "Helps deal with money.. 2 decimals..
In presence of argument, prints it at \(point\).
Note that rounding will NOT work, because you rounding means
(/ (float (round (* 100 arg))) 100), but the last division by 100
itself is suspect, and can spoil the entire effect achieved by
rounding. viz. (/ 234 100) can give 2.399999998. See?
Also see my definition of //"

  (interactive "P")
  (let* ((aa (eval-last-sexp nil))
         (bb (if (and (numberp aa) (not (integerp aa)))
                 (format "%.2f" aa)
               (format "%s" aa)))
         (standard-output t))
    (if internal-arg (insert bb) (prin1 bb))))

(defun // (&rest args)
  "My sensible definition of /.
Does not say 4 / 3 = 0. Note: this uses equal and not equalp, the
last time i checked , equalp seemed to work as well.. "
  (let ((aa (apply '/ args)))
    (if (equal (car args) (apply '* aa (cdr args)))
      (apply '/ (cons (float (car args)) (cdr args))))))

> -- 
> -- KB1FVD -- -=-=-=-=- Tov! Is qui iacit in hamas marsupiales.  | <-----
>   |  |  Rev. Irreverend Hacksaw, Omnibenevalent Polyparrot (ULC) | Melior
>   |XX| http://www.hacksaw.org -- http://www.privatecircus.com    |  amare
>   ---- <----- Omnia plures altus Latina videt. Annuit Crustum.   | chemia

--Deepak, http://www.glue.umd.edu/~deego
16:40 The documentations We sent  before you were no more than mortals
whom We inspired  with revelations and with writings.   Ask the People
of the Documentation, ii you doubt  this.  To you We have revealed the
Emacs-Manual, so that  you may proclaim to men  what has been revealed
to them, and that they may give thought.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]