integer division with float result

0ffh frank at frankhirsch.youknow.what.todo.net
Mon Nov 19 14:29:51 PST 2007


Stas Sergeev wrote:
> 0ffh Wrote:
>> Also: We have all understood your point. Some think the same as you,
>> some different. As it's a matter of tastes, you won't achieve much
>> more if you keep pressing it.
> I didn't think I was pressing it.

Maybe not, conceded.

> The guy said that the efficiency is the problem,
> and I said that I don't think so (perhaps I was wrong,
> but where is the pressure?).
> As for not reading the entire thread - very probably.
> For some reasons the thread got "split". The fragments
> that  I've found quickly, I've looked through, the others
> got slipped. :) (but search seems to help now)

It's just that I can't stand the long threads which are usually
caused when people try to argue about things which boil down to
a mere matter of preference. Those disagreements cannot, and so
will not, be resolved with technical (or any other) arguments.
Even if one of the possibilities were really objectively better
that doesn't help much unless it's by a rather wide margin.
The less difference it makes, the more unlikely it is that it's
convincing, the longer and more painful it all gets.
I just wanted to stop this short... =)

Now to something completely different: The efficiency thing.

If I make returning floats the default for integer division
then it will make actual integer division slow (three casts
and the float division) unless you have the compiler do type
inference. Type inference is not always possible. That means
we still need casts (only in different places now) plus extra
logic in the compiler to achieve nothing more than changing
to a different default behaviour, which is a matter of taste.
Q.E.D.

regards, frank



More information about the Digitalmars-d mailing list