Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function convertToBTCFromSatoshi($value){
- $BTC = ($value / 100000000 );
- return (float)$BTC;
- }
- php > echo 10000.00000001 * 2;
- 20000.00000002
- php > echo 100000.00000001 * 2;
- 200000.00000002
- php > echo 1000000.00000001 * 2;
- 2000000
- /** Convert Satoshis to a string that can be displayed to users.
- * input: $value Integer or string that can be parsed as an int.
- * output: string (eg: "1.00400000")
- */
- function convertToBTCFromSatoshi($value){
- return bcdiv( intval($value), 100000000, 8 );
- }
- rtrim($value, "0"); // trim zeros from the right-hand side
- function convertToBTCFromSatoshi($value) {
- $BTC = $value / 100000000 ;
- return $BTC;
- }
- function formatBTC($value) {
- $value = sprintf('%.8f', $value);
- $value = rtrim($value, '0') . ' BTC';
- return $value;
- }
- echo formatBTC(convertToBTCFromSatoshi(5000));
- 0.00005 BTC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement