Function: hif-string-to-decfloat
hif-string-to-decfloat is a byte-compiled function defined in
hideif.el.gz.
Signature
(hif-string-to-decfloat STRING &optional FIX EXP)
Documentation
Convert a C(++) decimal floating formatted string into float.
Assuming we've just regexp-matched with hif-decfloat-regexp and it matched.
if REMATCH is t, do a rematch.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/hideif.el.gz
(defun hif-string-to-decfloat (string &optional fix exp)
"Convert a C(++) decimal floating formatted string into float.
Assuming we've just regexp-matched with `hif-decfloat-regexp' and it matched.
if REMATCH is t, do a rematch."
;; In elisp `(string-to-number "01.e2")' will return 1 instead of the expected
;; 100.0; therefore we need to write our own.
;; This function relies on the regexp groups of `hif-hexfloat-regexp'
(if (or fix exp)
(setq fix (hif-delete-char-in-string ?' fix)
exp (hif-delete-char-in-string ?' exp))
;; rematch
(setq string (hif-delete-char-in-string ?' string))
(hif-full-match hif-decfloat-regexp string)
(setq fix (or (match-string 1 string)
(match-string 3 string)
(match-string 5 string))
exp (or (match-string 2 string)
(match-string 4 string)
(match-string 6 string))))
(setq fix (string-to-number fix)
exp (if (zerop (length exp)) ;; nil or ""
0 (string-to-number (substring-no-properties exp 1))))
(* fix (expt 10 exp)))