PHP realizes the method of converting scientific notation into original number string, counting string_PHP tutorial

WBOY
Release: 2016-07-13 10:11:39
Original
1548 people have browsed it

PHP implements the method of converting scientific notation into original number string, counting string

The example in this article describes how PHP implements the conversion of scientific notation into original numeric strings. It is shared with everyone for your reference.

The specific implementation code is as follows:

Copy code The code is as follows:
function NumToStr($num){
If (stripos($num,'e')===false) return $num;
$num = trim(preg_replace('/[='"]/','',$num,1),'"');//Scientific notation appears and is restored to a string
$result = "";
While ($num > 0){
$v = $num - floor($num / 10)*10;
$num = floor($num / 10);
$result = $v . $result;
}
Return $result;
}

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/928223.htmlTechArticlePHP implements the method of converting scientific notation into original numeric strings, counting strings. The example of this article tells the PHP implementation Method to convert scientific notation to original number string, share with...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!