Search code examples
phpcurrencybitcoinnano

I want to show a number in php which has 30 digits after decimal without rounding it up for nano currency, anyone have any Idea?


For example, if I have a number

$x = 340282366920938430000000000000000000000;

I want output as 340282366.92093 and not 340282366.92094 Also for a number like

$y = 23000000000;

I want the output to be 0.000000000000000000023


Solution

  • use string cast an bcdiv

    $number = '340282366920938430000000000000000000000';
    echo bcdiv($number, '1000000000000000000000000000000', 8);
    

    Return

    340282366.92093843