Skip to content

Instantly share code, notes, and snippets.

@obscuren
Created January 16, 2014 17:03
Show Gist options
  • Save obscuren/8458836 to your computer and use it in GitHub Desktop.
Save obscuren/8458836 to your computer and use it in GitHub Desktop.
// e = 10^21
e := big.NewInt(0).Exp(big.NewInt(10), big.NewInt(21), big.NewInt(0))
d := new(big.Rat)
d.SetInt(block.Difficulty)
c := new(big.Rat)
c.SetFloat64(0.5)
// d = diff / 0.5
d.Quo(d, c)
// base = floor(d)
base.Div(d.Num(), d.Denom())
x := new(big.Int)
x.Div(e, base)
// x = floor(10^21 / floor(diff^0.5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment