Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2012-05-17
06:29 • Closed ticket [3525462fff]: Expr documentation bug (expr {"0y" < &q... artifact: 224f69a5cb user: dkf
2012-05-10
19:55 • Ticket [3525462fff]: 3 changes artifact: ecd4a2aa8a user: dkf
08:30 • New ticket [3525462fff]. artifact: 87676f5fff user: zoltan3

Expr documentation bug (expr {"0y" < "0x12"})

Closed / Fixed3525462fffffffffffffffffffffffffffffffffCreated 15 years agoUpdated 15 years ago
Descriptionplain2012-05-10 08:30:16
Following can be seen in the expr's manual: expr {"0y" < "0x12"} returns 1, because it is done using string comparison after the second operand is converted to the string 18. But the command returns 0 in the Tcl interpreter.
In the manual, part "STRING OPERATIONS" we can see: "Because of Tcl's tendency to treat values as numbers whenever possible, except in the case of the eq and ne operators.". And I expect the same on the ground of the part "OPERANDS": "Where possible, operands are interpreted as integer values."

But is looks like a bug in the documentation. Only if both operands could be converted to numbers would their numerical values be compared.
dkf Ticket [3525462fff]: 3 changes [History diff]2012-05-10 19:55:07
dkfplain2012-05-17 06:29:42
allow_comments - 1

Hmm, it's not worked that way for a long time now (since at least 8.4.2, the oldest version I've got conveniently available). Corrected the docs to reflect reality.

At a guess, the original documented behavior was really a bug even at the time.
Log in (anonymous is fine) to add a comment.