Hello Terrence, some interaction with a fellow Tcler made me realise that this may be the "best" way to deal with NaNs of unclear denomination:
if { ![string is double $x] || $x != $x } { ... it is not a valid number or it is NaN } (sprintf() as used in the bindings will either produce a valid, ordinary number, something that is recognisable as NaN or something that can not be used as a number, hence NaN is a good way to deal with it.) I thought of putting the solution on the C side, but it is very probable that an optimising compiler will optimise away such comparisons as if (x != x) {...}. isnan() is not available for all compilers, but we provide a workaround, maybe that is a solution too. I will investigate further. Regards, Arjen On 2009-02-21 18:22, trc wrote: > Hi, > > I am using MSVC 9 with (Activestate) Tcl 8.5 > > Example 21 fails as follows - > > can't use non-numeric string as operand of "+" > while executing > "expr {$lzmax + 0.01}" > (procedure "x21" line 167) > invoked from within > "x21" > (file "./x21" line 18) > > > Printing $lzmax shows the value 1.#QNAN. > > The problem is that for the above configuration a NAN has the value > 1.#QNAN, which is not detected by proc isnan in examples/tcl/x21.tcl. > > Rather than add a specific test for 1#QNAN I propose using the more generic > tcl test > string is double $x > > Please find a patch attached. > > Kind regards > > > Terrence > > > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > > > ------------------------------------------------------------------------ > > _______________________________________________ > Plplot-devel mailing list > Plplot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/plplot-devel Delft Hydraulics, GeoDelft, the Subsurface and Groundwater unit of TNO and parts of Rijkswaterstaat have joined forces in a new independent institute for delta technology, Deltares. Deltares combines knowledge and experience in the field of water, soil and the subsurface. We provide innovative solutions to make living in deltas, coastal areas and river basins safe, clean and sustainable. DISCLAIMER: This message is intended exclusively for the addressee(s) and may contain confidential and privileged information. If you are not the intended recipient please notify the sender immediately and destroy this message. Unauthorized use, disclosure or copying of this message is strictly prohibited. The foundation 'Stichting Deltares', which has its seat at Delft, The Netherlands, Commercial Registration Number 41146461, is not liable in any way whatsoever for consequences and/or damages resulting from the improper, incomplete and untimely dispatch, receipt and/or content of this e-mail. ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel