如何获取哈希的数值?

How to get numeric value of a hash?

Proof of work 区块链 wiki 上,可以找到散列

0000c3af42fc31103f1fdc0151fa747ff87349a4714df7cc52ea464e12dcd4e9 

对应值2^239.61238653。我的问题是,如何计算散列的这个数值?

首先要注意的是,block hash通常表示为十六进制,littleendian value, when you try to convert to decimal. If your system是little-endian:

在bash/perl中转换为十进制:

$ hex=0000c3af42fc31103f1fdc0151fa747ff87349a4714df7cc52ea464e12dcd4e9
$ $ perl -le 'use bignum qw/hex/; print hex("0x".$ARGV[0])' --"$hex"
532607621168989936896605052113495566299419916018780134558135832581308350315356027254565114944

或者,获取 base2 日志:

perl -le 'use bignum qw/hex/; print log(hex($ARGV[0]))/log(2)' -- "$hex" 
239.6123865298365295145460775449928303015

代表2^239.61238653