[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] Bug in ns ? expr 100 + 0.1 returns 100.0999999999999 !!!!



On Tue, 16 Jan 2001, Heiler Matthias wrote:

> It's not a real bug.  In tcl/lib/ns-default.tcl you can find the line
> 
> ===
> set tcl_precision 17
> ===
> 
> which basically switches off rounding. 

...and makes Tcl about as accurate as it can be; see the Tcl FAQ:
http://psg.com/~joem/tcl/faq.html#IncreasingPrecision

Innocent question here. Given that ns has to bridge Tcl and C++,
wouldn't it be nice if the arithmetical accuracy was the same high
accuracy in both?

(Thinking of the satellite code, there's a lot of LEO orbit position
computation in C and spherical/cartesian conversion that might benefit
from Tcl's added precision, if not the resulting incredible
performance slowdown. Yup, more accurate C arithmetic would be nice.
Something to bear in mind when rewriting stuff in the other language
for convenience/speed.)

L.

<[email protected]>PGP<http://www.ee.surrey.ac.uk/Personal/L.Wood/>