From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <099ad3269e0c5d9db72f7b3bb1711ca3@felloff.net> Date: Tue, 3 May 2016 03:13:39 +0200 From: cinap_lenrek@felloff.net To: 9fans@9fans.net In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] store NaN() to memory traps on 386 (387) Topicbox-Message-UUID: 8e64111a-ead9-11e9-9d60-3106f5b1d025 > to cinap's point, either nan -> float doesn't trap, and there is no protection > against bad fp math, or it does trap, and one has protection against producing > inadvertant nans. > by the way, the same issue exists with sse. with SSE, i can assign SNaN's to variables and test for them with isNaN(). and only have the cpu trap when doing arithmetic on them, which i think is reasonable. but on 387, loading/storing the SNaN causes touble before i can even test for it. if NaN() produces a QNaN instead of a SNaN, then arithmetic will silently produce QNaN results, and we loose the protection for SSE. This is the behaviour when one clears FPINVAL from the FCR. for awk, i'm forced to one of these options with the current behaviour: - test the string before calling strtol() to make sure its proper decimal real number - clear FPINVAL in the FCR and loose the protection and test strtol() result with isNaN() both suck. if i'm going to have to parse the real number string myself to make sure its not nan, then what use is strtod()? and clearing FPINVAL just so i can test for isNaN() makes no sense. the program wasnt prepared to handle nan in the first place. maybe strtod() should not even parse "nan" when the FPINVAL bits are clear in the FCR an return 0.0 (similar to strtol) instead? So we interpret the FPINVAL bits in the FCR as "we dont want NaN's" and hence never produce them ourselfs? not sure whats worse... -- cinap