From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "josephoswald+gg@gmail.com" Newsgroups: gmane.emacs.help Subject: Re: How do I convert hex numbers to decimal ? Date: Mon, 5 Oct 2009 00:05:24 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <1bfadfca-66ba-4aec-bb90-eb3a460c660c@l13g2000yqb.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1254805152 1549 80.91.229.12 (6 Oct 2009 04:59:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 6 Oct 2009 04:59:12 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 06 06:59:03 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Mv28c-0004ov-GK for geh-help-gnu-emacs@m.gmane.org; Tue, 06 Oct 2009 06:59:02 +0200 Original-Received: from localhost ([127.0.0.1]:42575 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mv28b-0000xw-W2 for geh-help-gnu-emacs@m.gmane.org; Tue, 06 Oct 2009 00:59:02 -0400 Original-Path: news.stanford.edu!usenet.stanford.edu!postnews.google.com!q14g2000vbi.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.lang.lisp Original-Lines: 35 Original-NNTP-Posting-Host: 69.203.130.104 Original-X-Trace: posting.google.com 1254726324 4666 127.0.0.1 (5 Oct 2009 07:05:24 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 5 Oct 2009 07:05:24 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q14g2000vbi.googlegroups.com; posting-host=69.203.130.104; posting-account=jtqjlAkAAADCx2hem5Jng3owNog69q6J User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:173579 comp.lang.lisp:276821 X-Mailman-Approved-At: Tue, 06 Oct 2009 00:58:36 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:68692 Archived-At: On Sep 6, 9:03=A0pm, bolega 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 =3D 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)