Yes.
All numbers beginning with 0x are hexadecimal vaues and all remaining numbers beginning with 0 are octal values.
But if a number can't fall in these categories it is considered as float. And 09 is a bad octal value (octal digits are 0-7) and was considered as float.
09 being a floating-point is questionable but it was that expr did.
Octal values are no more used and remain an annoyance. You have to deal with.
From the expr page: OPERANDS A Tcl expression consists of a combination of operands, operators, and parentheses. White space may be used between the operands and operators and parentheses; it is ignored by the expression's instructions. Where possible, operands are interpreted as integer values. Integer values may be specified in decimal (the normal case), in octal (if the first character of the operand is 0), or in hexadecimal (if the first two characters of the operand are 0x). If an operand does not have one of the integer formats given above, then it is treated as a floating-point number if that is possible. Floating-point numbers may be specified in any of the ways accepted by an ANSI-compliant C compiler (except that the f, F, l, and L suffixes will not be permitted in most installations). For example, all of the following are valid floating-point numbers: 2.1, 3., 6e4, 7.91e+16. If no numeric interpretation is possible, then an operand is left as a string (and only a limited set of operators may be applied to it).
There is a TIP (Tcl Improvement Proposal) to remove this treatment of octal numbers for the 9.0 release. I strongly suspect that it will pass and be implemented, as octal numbers aren't used much these days. But the Tcl Core Team is very conservative about breaking backwards compatibility, so don't expect this change to occur before 9.0.
- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting,
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.