假設我有一個字符串,其中包含「7.2769482308e + 01」(該數字來自第三方軟件,我無法控制格式)。將呈現爲字符串的指數數字轉換爲小數
什麼是最便宜的方法將其轉換成十進制72.769482308
?
我能想到的唯一解決方案是分割十進制+指數部分並使用乘法。但可能在那裏建立它的功能做同樣的事情?
備註:夥計們,是的,我讀過Convert exponential to a whole number in PHP和Convert exponential number to decimal in php。這個問題是無關緊要的,因爲他們已經有一個數字,但我有一個字符串。
大聲笑,非常簡單......從來不知道PHP可以識別鑄造字符串指數格式。此行爲是否記錄在案? – zerkms 2011-03-17 14:21:59
@zerkms是的。 http://php.net/manual/en/language.types.string.php#language.types.string.conversion和http://php.net/manual/en/language.types.float.php – Wiseguy 2011-03-17 14:23:10
是的,文檔中存在以下內容:http://ru.php.net/manual/en/language.types.string.php#language.types.string.conversion – zerkms 2011-03-17 14:23:18