Re: OT: Need help with numeric bases
From: | Peter Clark <peter-clark@...> |
Date: | Tuesday, February 25, 2003, 16:25 |
On Tuesday 25 February 2003 09:44 am, H. S. Teoh wrote:
> Just have it return an empty string in an else-clause. I don't know how
> Python represents an empty string, but I suspect an 'else: return ""'
> should do the trick. :-)
Yes, I suspected that something like that would do the trick, except that in
my befuddled state last night I didn't trust myself not to screw something
up. :) Part of my brain was concocting all sorts of ways to deal with the
recursion, while the other part was saying, "No, stupid, it's much easier
than that!" So I went to bed.
> > Next up: floating numbers!
> Hmm, I had a crack at it this morning, but it turns out to be more tricky
> than I thought. One reason is that under your system, 2 ash can also be
> written as 1.8 ash, or 1.78 ash, or even 1.777778 ash. So depending on
> whether you want to force a specific number of octals/ashals, you'll have
> the script returning 1.778 ash for 2 ash, etc..
I don't know, but I had imagined the system to work like this:
1
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
2
But then I realized that I was inserting a zero, since "1" is really "1.0" and
"2" is really "2.0."
So, when in doubt, I turn to the old standby: what did the ancient Greeks do
for fractions and/or decimals? As far as I understand it, they didn't have
zero, but they had to have something to handle geometry.
:Peter
--
Oh what a tangled web they weave who try a new word to conceive!
Replies