literals

Don nospam at nospam.com
Sun Mar 28 13:46:20 PDT 2010


so wrote:
> Hello Don, finally!
> 
> It is hard to explain yourself when you don't know the people you talk 
> have numeric coding background.
> Since we know you have done much numeric and generic coding, it will be 
> enough for me if you understand what i mean/ask/want,
> and say what i am talking is ridiculous, or think that i am trolling, 
> just say so and i shut up! :)

You're definitely not trolling! I'm not 100% sure of which issue you're 
referring too, but I'm aware of a few, for example:

(1) Converting a floating point literal into a double literal is usually 
not lossless.
0.5f, 0.5, and 0.5L are all exactly the same number, since they are 
exactly representable.
But 0.1 is not the same as 0.1L.
So it's a bit odd that this silent lossless conversion is taking place.
It does have a very strong precedent from C, however.

(2) The interaction between implicit casting and template parameters is 
quite poor. Eg, the fact that '0' is an int, not a floating point type, 
  means that something simple like:
  add(T)(T x) if (isFloatingPoint!(T))
doesn't work properly. It is not the same as:
add(real x)
since it won't allow add(0).

Which is pretty annoying. Why can't 0 just mean zero???



More information about the Digitalmars-d mailing list