Skip to content

Instantly share code, notes, and snippets.

@HAOYUatHZ
Created June 13, 2018 12:14
Show Gist options
  • Save HAOYUatHZ/781490a910d13df7126e4eea416a1715 to your computer and use it in GitHub Desktop.
Save HAOYUatHZ/781490a910d13df7126e4eea416a1715 to your computer and use it in GitHub Desktop.
package main
import(
"fmt"
"math/big"
"github.com/bytom/consensus/difficulty"
)
func main() {
//net-work difficulty 5549086336
compact := uint64(0x1c00000000c62490)
i := difficulty.CompactToBig(compact)
fmt.Println(i) // 20866874690468587115166842246551058881100836709330530969291994431488
int1, _ := new(big.Int).SetString("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 0)
fmt.Println(int1) // 115792089237316195423570985008687907853269984665640564039457584007913129639935
o := big.NewInt(0).Div(int1, i)
fmt.Println(o) // 5549086336
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment