当我将手机号码从 CSV 文件导入数据库时​​,号码以 9.78E+12 格式存储。实数如何存储?

When I import mobile numbers from CSV file to database, the numbers are stored in 9.78E+12 format. How to store in actual number?

其中包含“9.77985E+12”格式的联系电话。我必须以这种格式“9779849561769”在 mysql 数据库中保存实际联系电话。 Excel 自动将数字转换为“9.77985E+12”格式。我需要使用 PHP 将“9.77985E+12”格式转换为“9779849561769”格式。我该怎么做?

我使用了第三方库,但它保存为“9.77985E+12”格式。

数据9.77985E+12是一个浮点数。当您需要精确值时,将浮点值转换为完整值通常不是一个好主意,因为您可能会失去初始值的精度。

您应该能够将 excel 中的单元格格式设置为 'text' 而不是 'integer',这将解决 excel 中的问题。

否则请在您的 PHP 中尝试转换它

echo number_format($float,10,'.','');

当我从 Microsoft excel 以 CSV 格式保存数字时出现问题,它失去了一定程度的精度。这发生在仅从我的计算机保存文件时。我尝试从另一台计算机保存文件,它有效。我不知道我的 excel 软件出了什么问题。

if this problems comes for a javascript user when exporting a csv in excel format, can use below method. that will solve the problem.

   let mobile = +941231234123
   let mobileForCsv = mobile + '\t';
    
   console.log(mobileForCsv) // +941231234123