[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: tostring(e,[base])
- From: Duncan Cross <duncan.cross@...>
- Date: Tue, 26 Jul 2011 12:27:28 +0100
On Tue, Jul 26, 2011 at 12:05 PM, Dirk Laurie <dpl@sun.ac.za> wrote:
> At present Lua has `tonumber (e [, base])` but only `tostring (e)`.
> For symmetry, `tostring (e [, base])` would be nice to have:
>
> F5 = 2^32+1
> p = 641
> q = F5/p
> print (tostring(q,2)).."₂" --> 11001100011101110000001₂
>
> Dirk
>
>
>
>
I disagree. It would feel odd to parameterize tostring() just for
adding a base, and not in arbitrary other extensible ways too, which I
feel would overcomplicate the function.
If anything, it shows that tonumber(e, base) should strictly be
separated out from tonumber(e) to a different function. But my
preference would be to just keep it as it is, the "asymmetry" really
doesn't seem like a problem.
-Duncan