floats default to NaN... why?

Jonathan M Davis jmdavisProg at gmx.com
Sat Apr 14 01:03:18 PDT 2012


On Saturday, April 14, 2012 09:58:42 F i L wrote:
> On Saturday, 14 April 2012 at 06:29:40 UTC, Ali Çehreli wrote:
> > On 04/13/2012 09:00 PM, F i L wrote:
> > > default is NaN
> > 
> > Just to complete the picture, character types have invalid
> > initial values as well: 0xFF, 0xFFFF, and 0x0000FFFF for char,
> > wchar, and dchar, respectively.
> > 
> > Ali
> 
> That's interesting, but what effect does appending an invalid
> char to a valid one have? Does the resulting string end up being
> "NaS" (Not a String)? Cause if not, I'm not sure that's a fair
> comparison.

You can't append a char to a char. You can append them to strings, but not 
each other.

Appending an invalid char results in a string with an invalid char. It won't 
blow up on its own. But any function which attempts to decode the string 
(which includes the vast majority of functions which would be called on a 
string) would result in a UTFException. So, you'll generally know that you 
have a bad string very quickly.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list