[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do I convert hex numbers to decimal ?
From: |
address@hidden |
Subject: |
Re: How do I convert hex numbers to decimal ? |
Date: |
Mon, 5 Oct 2009 00:05:24 -0700 (PDT) |
User-agent: |
G2/1.0 |
On Sep 6, 9:03 pm, bolega <gnuist...@gmail.com> wrote:
> I have a bunch of related questions, but the solution is desired in
> emacs lisp and to work inside emacs only.
>
> 1) How do I convert hex numbers to decimal ?
> 2) How do I convert ascii to the character that it represents, short
> of a table ? Any function or simpler algorithm ?
> 3) What are the variables and how to set their values ?
>
> read-quoted-char-radix
> quoted-char-radix
>
> 4) How do i find the emacs lisp code for C-x = to see how it gives the
> ascii of the char at the cursor and then use to find the reverse, ie
> ascii to char ?
>
> Thanks a lot to the star who can explain.
Emacs Lisp has
(string-to-number string &optional base)
Parse string as a decimal number and return the number.
This parses both integers and floating point numbers.
It ignores leading spaces and tabs.
If base, interpret string as a number in that base. If base
isn't
present, base 10 is used. base must be between 2 and 16
(inclusive).
If the base used is not 10, floating point is not recognized.
I found this in the Elisp Info documentation under String Conversion.
In your case you want to use (string-to-number "f00" 16)