The mpfr library actually initialises the mpfr_t data type with a value of NaN. It's something I sort of like - it implies (to me, anyway) that the developers, having no idea what value should be assigned initially, have quite appropriately assigned no value. It's up to the program to assign a value to the mpfr_t variable - and until that variable is assigned a value, it stays as NaN.
That, to me, makes perfect sense. If the programmer creates an mpfr_t variable, and subsequently tries to perform an operation upon it withouthaving initialised it, the operation raises an exception.
That seems to me to be directly analogous to:
my $x; $x *= 2; Use of uninitialized value $x in multiplication (*) at ...
Albeit that's a warning rather than fatal.
And equivalent to the trap that occurs when:
void something( char *x ) { printf( "%s\n", *x ); } ... char *s; something( s );
Raising an exception if teh programmer attempt to use a NaN value in an operation means that he will know about it if it happens, but can deal with it if it is a possibility and there is something sensible that he can do.
In reply to Re^3: NaNs are true
by BrowserUk
in thread NaNs are true
by syphilis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |