Prefixing octal numbers with 0o #2
klux21
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I did share new versions of the functions which support the prefixes 0o and 0O for octal values now.
Octal numbers are rarely used and most people don't even know what they are.
For this it was never a good idea to treat numbers as octal values if they have a leading 0.
Even more because this kind of logic would render floating point values like 0.1 an octal value that is decimal 0.125.
However, if the wrappers are used to replace the standard functions it's not a good idea to behave a different way for base 0 and a different behavior should be an optional thing that programmers need to use intentionally.
If the numeric base for a strtol family wrapper is set to 1 now the base becomes detected like if the base is set to 0 but the prefix 0o is required for specifying an octal number while all numbers which are prepended by leading zeros remain decimal values.
Beta Was this translation helpful? Give feedback.
All reactions