0
我從MongoDB的在藥劑
{
"id": "123",
"name": "foo",
"credit": 10000
}
拉一些數據由於某種原因,當我得到的信用作爲Float
類型與1.0e4
其值等於10000
科學記數法。
我如何解析它到正常顯示(10000)?
我從MongoDB的在藥劑
{
"id": "123",
"name": "foo",
"credit": 10000
}
拉一些數據由於某種原因,當我得到的信用作爲Float
類型與1.0e4
其值等於10000
科學記數法。
我如何解析它到正常顯示(10000)?
要轉換float
到integer
您可以使用round/1
或trunc/1
iex> round(10000.00)
10000
iex> trunc(10000.00)
10000
要輸出一個浮點數作爲一個整數字符串,可以使用:erlang.float_to_binary/2
iex> :erlang.float_to_binary(10000.00, decimals: 0)
"10000"
https://stackoverflow.com /問題/ 38734113 /仙丹變頻浮到字符串? – Dogbert