我如何在32位操作系统中存储BIGINT号 [英] How did I store a BIGINT number in a 32-bit OS

查看:206
本文介绍了我如何在32位操作系统中存储BIGINT号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在具有32位PIXEL OS(Raspbian版本)的raspberry pi 3(64位SoC)上运行LAMP堆栈。
我在MySQL中创建了一个新表,并将主键设置为未签名的BIGINT(20)。最初,我认为数据库只会截断溢出的数字或其他内容,但实际上它可以存储的数字超过40亿。更准确地说,我存储了数字5201702020。
这怎么可能?

I am running a LAMP stack on a raspberry pi 3 (64-bit SoC) with 32-bit PIXEL OS (a Raspbian version). I created a new table in MySQL and I set the Primary Key as unsigned BIGINT(20). Initially I thought that the database will just truncate the overflowing digits or something but it can actually store bigger numbers than ~4 billion. To be more precise I stored the number 5201702020. How is that possible?

推荐答案

查找MySQL源代码,我发现至少有4个对BIGINT的引用:

Looking in the MySQL source code, I found at least 4 references to BIGINT:

1) BIGINT:

1) "BIGINT":

  • https://github.com/mysql/mysql-server/blob/5.7/storage/innobase/pars/pars0lex.l#L560

que retorna PARS_BIGINT_TOKEN:

que retorna "PARS_BIGINT_TOKEN":

  • https://github.com/mysql/mysql-server/blob/5.7/storage/innobase/include/pars0grm.h#L247

2)作为结构:

  • https://github.com/mysql/mysql-server/blob/5.7/strings/dtoa.c#L627

3)在很多地方都像int64_t或uint64_t

3) As int64_t or uint64_t in many places

4)所有Java文件中的Java语言类型。

4) Java language type, in all java files.

然后,回答您的问题:

情况(1)和(2)将由源代码实现/逻辑处理。

The situations (1) and (2) will be handled by source code implementation/logics.

情况(3)将由以下方式处理编译器,而不是操作系统。编译器将对BigInt变量和值进行所有必要的转换以完成工作。

The situation (3) will be handled by the compiler, not the OS. The compiler will make all the necessary transformations to BigInt variables and values to accomplish the job.

情况(4)将由JVM处理,而不是由OS处理,因为

The situation (4) will be handled by JVM, not the OS, as the compiler does.

这篇关于我如何在32位操作系统中存储BIGINT号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆