Get the latest tech news

Dear String-to-Integer Parsers


These are very useful functions that any language with distinct string and integer types will include in their standard library. Pass in a string with decimal digits and it’ll return the equivalent in the binary integer form that you can do mathematics with.

Pass in a string with decimal digits and it’ll return the equivalent in the binary integer form that you can do mathematics with. Maybe the programmer wanted to limit an input to 1000, but instead of using the less-than operator on the integer like a normal person, they check that the length of the string less than 4. While we’re on the subject of hex numbers, I may be following this up with a proposal that “H” should mean “times 16 to the power of” in a similar style, but that’ll be for another day.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Integer

Integer

Photo of parsers

parsers

Photo of Dear String

Dear String

Related news:

News photo

Unexpected security footguns in Go's parsers

News photo

Making any integer with four 2s

News photo

Integer addition algorithm could reduce energy needs of AI by 95%