emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r117370: * lisp/progmodes/hideif.el (hif-string-to-n


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r117370: * lisp/progmodes/hideif.el (hif-string-to-number): Don't return float for
Date: Thu, 19 Jun 2014 21:08:51 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117370
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17807
author: William Xu <address@hidden>
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Thu 2014-06-19 17:08:44 -0400
message:
  * lisp/progmodes/hideif.el (hif-string-to-number): Don't return float for
  hex integer constants.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/progmodes/hideif.el       hideif.el-20091113204419-o5vbwnq5f7feedwu-39
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-06-19 14:58:57 +0000
+++ b/lisp/ChangeLog    2014-06-19 21:08:44 +0000
@@ -1,3 +1,8 @@
+2014-06-19  William Xu  <address@hidden>
+
+       * progmodes/hideif.el (hif-string-to-number): Don't return float for
+       hex integer constants (bug#17807).
+
 2014-06-19  Stefan Monnier  <address@hidden>
 
        * international/mule-util.el (truncate-string-ellipsis): New var.

=== modified file 'lisp/progmodes/hideif.el'
--- a/lisp/progmodes/hideif.el  2014-03-20 18:22:17 +0000
+++ b/lisp/progmodes/hideif.el  2014-06-19 21:08:44 +0000
@@ -412,9 +412,13 @@
   (if (or (not base) (= base 10))
       (string-to-number string base)
     (let* ((parts (split-string string "\\." t "[ \t]+"))
-          (frac (cadr parts))
-          (quot (expt (* base 1.0) (length frac))))
-      (/ (string-to-number (concat (car parts) frac) base) quot))))
+           (frac (cadr parts))
+           (quot (expt (* base 1.0) (length frac)))
+           (num (/ (string-to-number (concat (car parts) frac) base)
+                   quot)))
+      (if (= num (truncate num))
+          (truncate num)
+        num))))
 
 (defun hif-tokenize (start end)
   "Separate string between START and END into a list of tokens."


reply via email to

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