2 ms·
> Big Insight #2 is that atoi() behaves as a (bad) hash function on ordinary text. It consumes characters and updates a 16-bit integer. I could have sworn I re
by zahlman 9mo ago
> Big Insight #2 is that atoi() behaves as a (bad) hash function on ordinary text. It consumes characters and updates a 16-bit integer.
I could have sworn I remembered atoi() being defined to return 0 for invalid input (i.e. text not representing an integer in base ten).
- MobiusHorizons 9mo agoThat would be true of one using a libc, but in a boot sector, you only have the bios, so the atoi being referenced is the one defined in c near the beginning of the article
- zahlman 9mo agoAh, I somehow skipped over that exact code block on first read.