Skip to content

Instantly share code, notes, and snippets.

@jcbozonier
Created January 16, 2017 14:49
Show Gist options
  • Save jcbozonier/3298785cb5532c8ff3db99cf307493d8 to your computer and use it in GitHub Desktop.
Save jcbozonier/3298785cb5532c8ff3db99cf307493d8 to your computer and use it in GitHub Desktop.
Multiplication in log-space until 0 (negative infinity in log-space)
import numpy as np
aggregate_product = np.log(1)
iterations = 0
while aggregate_product != float('-inf'):
aggregate_product += np.log(0.5)
iterations += 1
# break program execution and then print out
print(iterations)
print(aggregate_product)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment