Emacs Lisp: Convert Int/Float/String

By Xah Lee. Date: . Last updated: .

Convert Integer to Float

;; int to float
(float 3) ; 3.0

Convert Float to Integer

(truncate 3.3) ; 3
(floor 3.3) ; 3
(ceiling 3.3) ; 4
(round 3.4) ; 3

(info "(elisp) Numeric Conversions")

Convert String and Number

(string-to-number "3")
(number-to-string 3)

You can also use format to convert number to string. [see Format String]

(info "(elisp) String Conversion")

Emacs Lisp String

Lisp Basics

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Lisp Basics

Basics

Lisp Data Structure

Function

Lisp Symbol

Lisp Misc

Working with Elisp