Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2026-02

StrToInt documentation misses a functionality (maybe two?)

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Guillermo Martínez Jiménez

Hi again,

A few weeks ago I was looking on the Internet if there's a simpler way to convert a binary string (i.e. '00100101') to integer than using a loop and parsing it by hand. On Reddit I found an answer that suggests to use sysutils.StrToInt preceding the string with character '%'.

I tested and it works, so I go to the documentation to see if it also converts octal numbers but the documentation only mentions hexagesimal strings preceded by 'x', no mention to binary or octal.

I didn't test system.Val though but maybe it also allows binary and octal strings.

I know binary and octal strings aren't used often today but I think that the documentation should be updated.

Regards,
Guillermo Martínez J.

Bart
to Guillermo Martínez Jiménez
Show quoted text 5 lines
A few weeks ago I was looking on the Internet if there's a simpler way to convert a binary string (i.e. '00100101') to integer than using a loop and parsing it by hand. On Reddit I found an answer that suggests to use sysutils.StrToInt preceding the string with character '%'.
I know binary and octal strings aren't used often today but I think that the documentation should be updated.

The documentaion about val
(https://www.freepascal.org/docs-html/rtl/system/val.html) clearly says it handles binary, hexadecimal and octal input. and so does the docs about StToInt
(https://www.freepascal.org/docs-html/rtl/sysutils/strtoint.html).

Bart