An interesting observation
Daniel Keep
daniel.keep.lists at gmail.com
Fri Nov 9 19:11:54 PST 2007
Bruce Adams wrote:
> ...
>
> I can kind of see where your coming from with the div / argument. D like C++ has inherited C's nasty expression casting.
>
> float A, B, C;
> C=B/A; vs. C = B DIV A; use integer only division
> int x,y;
> C=cast(float)(x)/y; vs. C = x/y; use floating division
>
> Using a cast here to express your intent is ugly and wrong. Different function names are a more correct way to express intent. You could roll your own of course (bonus points for conciseness). I wonder if there is any compiler bonus to be had by the distinction though (the hidden rounding in x = A/B for example could catch a noob unawares)?
>
> ...
>
> Bruce.
We could use downs' trick to define a new infix operator!
C = x /fdiv/ y;
Shorter, and more obvious! Probably. To some people :P
-- Daniel
More information about the Digitalmars-d
mailing list