proposed syntax change

Don nospam at nospam.com
Fri Aug 7 00:13:53 PDT 2009


Paul D. Anderson wrote:
> I was browsing the Python spec yesterday and came across this interesting and useful syntax:
> 
> "/" (one slash) means floating point division, e.g. 5/2 = 2.5 even though 5 and 2 are integers
> 
> "//" (two slashes) means integer (floor) division, e.g. 5.0//2.0 = 2.0 even though 5.0 and 2.0 are floats.
> 
> I've always been a little troubled by the standard division operator being dependent on the types of the operands. 

Division of floats is also dependent on the rounding mode. There's 
actually no unabiguous "floating point division".

float f = ulong.max / 2.0;

Can't be represented exactly in a float, so it has to perform rounding.

The operator which is REALLY missing is exponentiation.



More information about the Digitalmars-d mailing list