[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New library num-base-converters

From: Tino Calancha
Subject: Re: New library num-base-converters
Date: Tue, 15 Aug 2017 18:49:45 +0900 (JST)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)

On Tue, 15 Aug 2017, Stefan Monnier wrote:

+(defun nbc-number-base-converter (num base-in base-out)
+  "Translate NUM, a string representing an integer, to a different base.
+BASE-IN, an integer, is the basis of the input NUM.
+BASE-OUT, an integer, is the basis to display NUM."

Having a string as both input and output is a bad API, I think.
It's better API than not having API at all; it provides me the flexibility
to handle input as '0xff', '#xff' or 'ff'.  Not that bad.

All one needs is basically to add a `base` arg to number-to-string
(there's already one for string-to-number).
Then we are again limited to 2 < b < 16 bases.  In the old thread
the OP asking for this feature wanted to use base 36.
The presented lib can handle 2 <= b <= 36.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]