Re: More math - must be bug(?)

At 2008-02-14 09:09AM, "ZB" wrote:
tclsh8.5 [~/tmp]set a -0
tclsh8.5 [~/tmp]puts [::tcl::mathfunc::int $a]
tclsh8.5 [~/tmp]puts [::tcl::mathfunc::abs $a]
tclsh8.5 [~/tmp]puts [::tcl::mathfunc::abs $a]

As you can see, "int" does the operation "absolute value" properly - when
"abs" does not?

I think you've found a bug in ::tcl::mathfunc::abs. File it on the Tcl
bug tracker at sourceforge

Note that when you use expr, result is correct:
% expr {abs(-0)}

I see in the expr docS that when Tcl sees:
expr {sin($x+$y)}
it actually does
tcl::mathfunc::sin [expr {$x+$y}]

expr still processes the function arguments (!)

so we see the error:
% ::tcl::mathfunc::abs -0

% expr {-0}

Therefore, as a workaround, you should wrap your mathfunc arguments in
set abs [::tcl::mathfunc::abs [expr {$a}]]

Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry