dou31797719 2016-10-04 07:24
浏览 58
已采纳

BIGINT改为指数级

I have a sqlite table - addresses as below:

+-----------------------------+
|   appid   |   BIGINT (20)   |
|  address  |   CHAR(300)     |
|   addr_id |   BIGINT(11)    |
+-----------------------------+

However, when I try to save data in appid with very large number, I get something like 9.0916073007e+18. I tried using real but that did not work either.

How should I fix this issue?

EDIT:

$qry = "select * from addresses WHERE id  = 18";
$result = $db->query($qry);
while($row = $result->fetchArray(SQLITE3_ASSOC) ){
     var_dump($row['appid']);  // float(9.0916073007e+18)
}
  • 写回答

1条回答 默认 最新

  • dsm1998 2016-10-04 08:07
    关注

    SQLite supports signed 64-bit integers, i.e., values up to 9223372036854775807:

    sqlite> create table t(x);
    sqlite> insert into t values(9223372036854775807);
    sqlite> select * from t;
    9223372036854775807
    

    However, the PHP documentation says:

    The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). 64-bit platforms usually have a maximum value of about 9E18, except on Windows prior to PHP 7, where it was always 32 bit.
    […]
    If PHP encounters a number beyond the bounds of the integer type, it will be interpreted as a float instead.

    So you have to upgrade to a recent enough 64-bit version of PHP. Or handle the values as strings.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?