integer division with float result

Lars Noschinski lars-2006-1 at usenet.noschinski.de
Mon Nov 19 02:59:01 PST 2007


* Stas Sergeev <stsp at aknet.ru> [07-11-19 06:46]:
>Bill Baxter Wrote:
>> Comparing with dynamically typed languages like Python isn't useful
>> because in Python a/2 can return an integer for if a==4 a float if a==5.
>>   A statically typed language like D doesn't have that luxury.
>Of course, but there is no problem to make the / op to
>just always return float, or is there?

Efficiency and accuracy. An integer division is faster than a float
division. Also, not all integer values can be represented exactly as
floats.



More information about the Digitalmars-d mailing list