Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library

Comment by comicjk

4 years ago

When I'm explaining logarithms, I find it helps to relate it to the number of digits. This code is a good example of the concept: you don't need log, just convert the int to a string and check its length. A string with 1-3 digits is bytes, 4-6 is kb, etc.

0 comments

comicjk

Reply

No comments yet

Contribute on Hacker News ↗

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities