【问题标题】:What is maximum value of int or long in Google App Engine datastore?Google App Engine 数据存储区中 int 或 long 的最大值是多少?
【发布时间】:2013-11-23 23:31:02
【问题描述】:

Google App Engine Python 中 IntegerProperty、LongProperty 的最大值是多少?

【问题讨论】:

    标签: google-app-engine google-cloud-datastore


    【解决方案1】:

    IntegerProperty 是 int 或 long:

    int 或 long 一个整数值,最多 64 位。

    Python int 值在存储之前转换为 Python long 值。存储为 int 的值将作为 long 返回。

    如果分配了大于 64 位的 long,则仅存储最低有效 64 位。

    为了更清楚起见,您可以使用 sys.maxint 来查找实际值(在 shell 中运行它并首先“导入 sys”)

    【讨论】:

    • 我认为 sys.maxint != datastore maximum int 所以我不会使用它。需要大约 46 位,所以它是完美的类型。
    【解决方案2】:

    Google App Engine 上没有 LongProperty,而只有 IntegerProperty,并且如前所述,它是一个 64 位有符号整数。

    此号码的最小值为−9,223,372,036,854,775,808,最大值为9,223,372,036,854,775,807

    【讨论】:

    • java 也一样?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-16
    • 2013-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多