|
2005-09-11
| ||
| 09:20 | • Closed ticket [1273713fff]: Expr with acos plus 6 other changes artifact: e778401a4d user: sf-robot | |
|
2005-08-28
| ||
| 00:51 | • Ticket [1273713fff]: 5 changes artifact: c4c6de017c user: dkf | |
|
2005-08-27
| ||
| 00:58 | • Pending ticket [1273713fff]. artifact: 59ef054a6a user: msofer | |
| 00:33 | • Ticket [1273713fff]: 4 changes artifact: f2105a92c8 user: alvinpleung | |
| 00:33 | • Add attachment bug.tcl to ticket [1273713fff] artifact: a4743159b4 user: alvinpleung | |
| 00:33 | • Ticket [1273713fff] Expr with acos status still Open with 4 other changes artifact: 092b7e8f01 user: alvinpleung | |
|
2005-08-26
| ||
| 15:46 | • Ticket [1273713fff]: 4 changes artifact: de7b2d127f user: dkf | |
| 08:13 | • Ticket [1273713fff]: 4 changes artifact: d461568450 user: msofer | |
| 07:38 | • Ticket [1273713fff]: 4 changes artifact: a9cf89710b user: alvinpleung | |
| 07:38 | • Add attachment bug.tcl to ticket [1273713fff] artifact: 87daec93ef user: alvinpleung | |
| 00:38 | • New ticket [1273713fff] Expr with acos. artifact: 0542bcb848 user: alvinpleung | |
Expr with acos
Closed / Invalid1273713fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-08-26 00:38:28
set factor2 [expr ($x0x1 - $y1_sqrt_factor1) * $denominator] [expr acos($factor2)] works set factor2 [expr acos(($x0x1 - $y1_sqrt_factor1) * $denominator)] failed with error message domain error: argument not in valid range
alvinpleungplain2005-08-26 07:38:29
File Added - 147014: bug.tcl
msoferplain2005-08-26 08:13:32
Logged In: YES user_id=148712 Can you provide a complete session log, including the values of your variables? Are you sure that they have the same values in both cases? The error message indicates that (Tcl thinks that) the argument to 'acos' is not between -1 and 1 % set a 2 2 % set b 1 1 % set c 0.5 0.5 % set f [expr acos(($a-$b)*$c)] 1.0471975512 % set c 2 2 % set f [expr acos(($a-$b)*$c)] domain error: argument not in valid range
dkfplain2005-08-26 15:46:48
Logged In: YES user_id=79902 Sounds as if your code is working at very close to the boundary values, which is usually problematic. FWIW, when I'm working out angles, I try to atan2() which has far fewer annoying cases than the rest of the inverse trig functions.
alvinpleungplain2005-08-27 00:33:00
Logged In: YES user_id=958624 I already attached the complete test case in the original bug report. It is currently shown in the "Attached Files" section with description "test case." The problem case is when ($a - $b) * $c eval to 1.0. I will attach the test case again.
alvinpleungplain2005-08-27 00:33:01
File Added - 147105: bug.tcl
msoferplain2005-08-27 00:58:58
Logged In: YES
user_id=148712
Oops - sorry, had not seen the attached file. I did take a
look at the new "Full test case" (it is missing a paren in
line 51, but this is irrelevant for this bug report)
The problem is caused by the fact that your expressions in
line 50 and 51 are not {}'quoted. This causes the values of
the variables to be re-read from their string
representation, with some loss in precision if tcl_precision
is less than 17 (it is 12 by default). This is not really a bug.
So there are two possible fixes (and I recommend using both):
(1) do {}'quote your expressions: it is much faster, it does
not produce these effects, and is almost always the right
thing to do. There are few cases where you may want two
substitution rounds (one by the tcl interpreter, one by the
[expr]) interpreter). If that is what you're after, it will
be clear to you.
(2) do 'set ::tcl_precision 17' when working with doubles
(but see http://www.tcl.tk/man/tcl8.4/TclCmd/tclvars.htm#M39
for some gotchas)
dkfplain2005-08-28 00:51:18
Logged In: YES user_id=79902 Note for people reading this in the future: in 8.5, the right thing to do will be to leave tcl_precision set to its default value. The advice on setting it to 17 is only correct up to 8.4 (or rather some version from the alpha cycle of 8.5, but that's an internal matter).
sf-robotplain2005-09-11 09:20:10
Logged In: YES user_id=1312539 This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker).
Log in (anonymous is fine) to add a comment.
Attachments:
- bug.tcl [download] added by alvinpleung on 2005-08-27 00:33:01. [details]