Skip to content

Instantly share code, notes, and snippets.

@johnmyleswhite
Created September 13, 2016 02:52
Show Gist options
  • Save johnmyleswhite/013eea1a59de435167b9b8a9ebca46df to your computer and use it in GitHub Desktop.
Save johnmyleswhite/013eea1a59de435167b9b8a9ebca46df to your computer and use it in GitHub Desktop.

Using a 64-bit floating point number (AKA a double), what is the smallest integer n such that?

  • 0.1^n == 0.0
  • 10.0^n == Inf
  • exp(-n) == 0.0
  • exp(n) == Inf

I frequently forget these numbers, so here they are:

  • 0.1^n == 0.0: n = 324
  • 10.0^n == Inf: n = 309
  • exp(-n) == 0.0: n = 746
  • exp(n) == Inf: n = 710
@johnmyleswhite
Copy link
Author

tanh(n) == 1.0: n = 20 via https://twitter.com/stephentyrone

@johnmyleswhite
Copy link
Author

  • 1 / (1 + exp(-n)) == 1.0: n = 37
  • 1 / (1 + exp(n)) == 0.0: n = 710

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment