我有用1e8转换的整数值4567,它变为0.00004567,所以我的问题是如何在PHP中将其转换回4567?
答案 0 :(得分:-2)
您可以使用number_format()例如
将其转换回使用number_format($scientific, 0, '.', '');
<?php
function makeScientificNumber($number){
$power = ($number % 10) - 1;
return ($number / pow(10, $power)) . "e" . $power;
}
function makeNormalNumber($scientific){
return number_format($scientific, 0, '.', '');
}
$number = 4567;
$scientific_number = makeScientificNumber($number);
echo "Scientific number is = $scientific_number";
echo PHP_EOL;
$normal_number = makeNormalNumber($scientific_number);
echo "Normal number is $normal_number";
?>
输出:
Scientific number is = 0.004567e6
Normal number is 4567