Once upon a time, Sven Barth said: > On 21.02.2013 21:01, Ewald wrote: >> >> Apparently the StrToInt function interprets strings starting with an `x` >> as hexadecimal numbers? This behaviour seems rather strange to me >> (strings starting with 0x would be a bit more understandable, but then >> again, we're programming pascal here, not C) and it is not mentioned in >> the documentation. What do I do with it? > > IntToStr simply calls through to Val and there is documented (more or > less) that it supports binary (%), octal (&) and hexadecimal ($, 0x) > values as well (see here: > http://www.freepascal.org/docs-html/rtl/system/val.html ). That it > also supports 'x' and 'X' as a prefix for hexadecimal values is > because of Delphi compatibility. > > As a sidenote: the prefixes %, & and $ can be used in normal source > code as well. Of course, these I use, but the `xabcd` syntax cannot be used in source code to represent numbers. Hence my confusion about what to do with it.
> >> A- File a bug concerning incomplete documentation? >> B- File a bug concerning incorrect behaviour of StrToInt()? >> C- Do nothing and live with it. >> D- ....? > > I'd say A. On the one hand a reference from StrToInt(64), > StrToInt(64)Def and TryStrToInt(64) to Val should be added and on the > other hand Val's documentation should be extended by the fact that > '0x', 'X' and 'x' are valid prefixes for hexadecimal values as well. > And while we're at it references from the 32bit StrToInt variants to > the 64bit variants could be added as well (they do exist the other way > round as one can see here: > http://www.freepascal.org/docs-html/rtl/sysutils/strtoint64.html ). > > So if you would please be so kind to open a bug report :) Here you go: http://bugs.freepascal.org/view.php?id=23933 :-) -- Ewald
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel