floats default to NaN... why?
Silveri
silv3ricedragon at gmail.com
Sat Apr 14 03:38:44 PDT 2012
On Saturday, 14 April 2012 at 07:52:51 UTC, F i L wrote:
> On Saturday, 14 April 2012 at 06:43:11 UTC, Manfred Nowak wrote:
>> F i L wrote:
>>
>> 4) use hardware signalling to overcome some of the limitations
>> impressed by 3).
>
> 4) I have no idea what you just said... :)
On Saturday, 14 April 2012 at 07:58:44 UTC, F i L wrote:
> 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.
The initialization values chosen are also determined by the
underlying hardware implementation of the type. Signalling NANs
(http://en.wikipedia.org/wiki/NaN#Signaling_NaN) can be used with
floats because they are implemented by the CPU, but in the case
of integers or strings their aren't really equivalent values.
On Saturday, 14 April 2012 at 07:45:58 UTC, F i L wrote:
> My original post was inspired by me showing my D code to
> another C# guy earlier, and coming up with poor explanations as
> to why floats where required to be defaulted in my math lib.
> His reaction what along the lines of my first post.
I think the correct mindset when working in D is to think that
"all variables should be initialized" and if you get incorrect
calculations with zero values, division by zero errors or nan
errors the most likely mistake is often that this guideline was
not followed.
More information about the Digitalmars-d-learn
mailing list