convert scientific notation to decimal with php

前端 未结 3 1934
盖世英雄少女心
盖世英雄少女心 2021-01-29 05:56

math with bitcoin is giving me problems

        $value = bcmul((float)$TotalMoney, $p,8);
        $value = bcdiv((float)$Value, 100,8);

returns

3条回答
  •  北海茫月
    2021-01-29 06:16

    Use the exemple below to convert Scientific Notation to float/decimal on PHP:

    echo sprintf('%f', floatval('-1.0E-5'));//default 6 decimal places
    echo sprintf('%.8f', floatval('-1.0E-5'));//force 8 decimal places
    echo rtrim(sprintf('%f',floatval(-1.0E-5)),'0');//remove trailing zeros
    

提交回复
热议问题