Convert exponential number represented as decimal string

Suppose I have a string , which contains "7.2769482308e + 01" (this number comes from third-party software, I can not control the format).

What is the cheapest way to convert it to decimal 72.769482308 ?

The only solution I can think of is to split the decimal + exponential part and use multiplication. But can there be some kind of built-in function to do the same?

NOTE : Guys, yes, I read Convert exponent to integer in PHP and Convert exponential number to decimal in php . And these questions do not matter, since they already have a number, but I have a line .

+7
source share
3 answers

How about a simple cast to a float?

 $string = "7.2769482308e+01"; $float = (float) $string; 
+13
source

I had success using number_format(1.2378147769392E+14, 0, '', '') , which was originally provided by this question .

This also works when the value is a string, for example: number_format("1.2378147769392E+14", 0, '', '') . Let's try.

+4
source

Here is very cheap: $float = "7.2769482308e+01" + 0;

0
source

All Articles