From 83f61b25fe896112420e4b9d00b7db8c8b6d8bcf Mon Sep 17 00:00:00 2001 From: William Xu Date: Thu, 19 Jun 2014 14:18:36 +0800 Subject: [PATCH] Convert non-decimal integer string still as an integer. (hif-string-to-number): e.g., Change (hif-string-to-number "0F" 16) to return `15' instead of `15.0'. --- lisp/progmodes/hideif.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/hideif.el b/lisp/progmodes/hideif.el index bcb4659..ee144df 100644 --- a/lisp/progmodes/hideif.el +++ b/lisp/progmodes/hideif.el @@ -412,9 +412,13 @@ that form should be displayed.") (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." -- 2.0.0