A use for integer quotients
Just van Rossum
just at letterror.com
Mon Jul 23 16:39:15 CEST 2001
> [Just van Rossum]
> > Do you really want 2047 bytes to be shown as 1 kbyte?
> > Integer division is a lousy tool in this particular example...
> Just, this is stupid, wrong, and gratuitously insulting,
> and therefore, in my opinion, ugly and nasty.
I think you're terribly overreacting. Sorry if I offended anyone,
I admit that first line of mine is a dumb assumption. To put it more
subtly: *I* would never use int arithmetic for this sort of thing in
> As for the second line: do you really think
> int(float(bytes)/float(k)+.5) is signigicantly better for rounding?
1) only one of the / operands need to be a float to force a float
outcome, and 2) there is a round() builtin function. Now, if we
initialize k to a float, we can write it like so:
I really don't see how the int examples you gave are in any way superior.
> If so, that is a statement of anti-integer float-religion preference,
> not fact.
Maybe. Integer arithmetic like may be a lot more natural if you have a
strong C background, and if not wasting cycles is a priority. To me
(no strong math background, no computer science education) it simply
looks like "showing off" to do a simple thing like this with ints. But
I'm sure you'll see an insult in that line, too.
> I am beginning to think that there is something wrong with a proposal
> that apparently has to be promoted by bulldozing away reasonable
Look, all I did was point out that for *this* particular example *I*
think it's not appropriate to use int division. I have not taken postition
either way, in fact I'm afraid of this change, too. All I know is that I
would've preferred the proposed behavior in the first place, but I'm
not so sure about adding it now, so late in the game.
More information about the Python-list