December 15, 2009
bearophile, el 15 de diciembre a las 16:14 me escribiste:
> Don:
> 
> > Bob Jones:
> > > double y = a / double(b);
> 
> > OK, I misunderstood you. You're completely right. At least my proposal won't let them slip through silently. I don't think we can do anything else without silently breaking C compatibility.
> 
> A silly idea that may keep C compatibility and avoid that cast: instead of an integer division operator it can be added a operator that always performs a floating point division, as:
> int a = 5, b = 7;
> double y = a \\ b;
> (I don't like that much, Pascal is better here).

What about ./ for floating point division? Maybe it introduces some kind of ambiguity with 1./2, but fortunately the result should be the same if that means 1. / 2 or 1 ./ 2: 0.5 =)

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
He andáu muchos caminos, muchos caminos he andáu, Chile tiene el buen vino y Suecia, el bacalao. Esta'o Unido tiene el hot do', Cuba tiene el mojito, Guatemala, el cornalito y Brasil la feishoada.
December 16, 2009
On Dec 16, 09 06:17, Nick Sabalausky wrote:
> "KennyTM~"<kennytm@gmail.com>  wrote in message
> news:hg90tu$22od$1@digitalmars.com...
>> On Dec 16, 09 05:14, bearophile wrote:
>>> Don:
>>>
>>>> Bob Jones:
>>>>> double y = a / double(b);
>>>
>>>> OK, I misunderstood you. You're completely right. At least my proposal
>>>> won't let them slip through silently. I don't think we can do anything
>>>> else without silently breaking C compatibility.
>>>
>>> A silly idea that may keep C compatibility and avoid that cast: instead
>>> of an integer division operator it can be added a operator that always
>>> performs a floating point division, as:
>>> int a = 5, b = 7;
>>> double y = a \\ b;
>>> (I don't like that much, Pascal is better here).
>>>
>>> Bye,
>>> bearophile
>>
>> Just introduce real fdiv(real, real)  (or /fdiv/) if this is the solution.
>> Works right now without changing the language.
>
> Reserving the only division operator for intdiv-only for the sake of C
> compatibility would be terrible design.
>
>

Just introduce real fdiv(real, real)  (or /fdiv/) **if this is the solution.**

One could also force / to return a real and introduce intdiv(). <off-topic>but if C compatibility is to be broken I'd like to see the comma operator be replaced instead.</off-topic>

1 2 3 4
Next ›   Last »