2017-04-09 73 views
-2

當我嘗試聲明浮點變量的值很小時,它會更改記號。用科學記數法保存小浮點數而不是小數點

Global $interior = 0.00008972 
MsgBox(4096, "1", $interior) 
$file = FileOpen("Balance.txt", 2) 
FileWrite($file, ""&$interior) 
FileClose($file) 

它顯示並寫入文件8.972e-005而不是0.00008972。

+1

它們是相同的浮點值 - 只是規範化。 (使用它來確認:https://web2.0calc.com/)輸出:猜測:如果你想以特定的格式顯示它,請看:https://www.autoitscript.com/autoit3/docs/functions/StringFormat .htm? –

+0

我想寫一個文件時,我做的文件內容是8.972e-005而不是0.00008972 這是問題 –

+0

[相關](https://stackoverflow.com/questions/30304690/converting-8-位十六進制數至十進制/ 30309114#30309114)。 – user4157124

回答

1

您可以使用StringFormat指定浮點值所需的精度。

Global $interior = 0.00008972 
$interior = StringFormat("%.8f", $interior) 
MsgBox(4096, "1", $interior) 
$file = FileOpen("Balance.txt", 2) 
FileWrite($file, ""&$interior) 
FileClose($file) 
相關問題