Satoshi to BTC
(Mathematical formula: Value * 10 ^ -8):
$satoshi = 5000; //Satoshi to btc echo number_format(($satoshi)*(pow(10, -8)), 8, '.', ''); //Returns 0.00005000
BTC to Satoshi
(Mathematical formula: Value * 10 ^ 8):
$btc = 0.00005; //Btc to satoshi echo ($btc)*(pow(10, 8)); //Returns 5000
Explanation
pow() - Exponential expression number_format($var, 8, '.', '') - Returns a number eight decimal places
manpreet
Best Answer
2 years ago
I am having PHP calculation problems (I think - i am reasonably new to PHP).
I am using
If $value = 10000 the result is correct of "0.0001"
Yet if $value = 5000 the result is "-5.0E-5"
Any ideas please :-)