当前位置:网站首页>[Lua] Int64 support
[Lua] Int64 support
2022-07-04 22:40:00 【Rice shrimp】
In the previous version ,lua Only by default double type , Although it can be modified luaconf.h The definition in lua number Change it to int64, But for int64 Type abandonment double Obviously not , Belong to attend to one thing and lose the other .
that , about 64bit There are many solutions for , The basic idea is to use 8bytes Of string / lightuserdata / userdata Modify the meta table to realize .
We In general use 8bytes Long string To represent a int64 . This can be the only key use , Without complex extensions , It belongs to a better way .
If you want to deal with it directly in the project 64bit Of timestamp. It needs to be right int64 Do mathematical operations . stay luajit in , I defined one userdata And overload its operator to complete . You can use ffi.cast("int64_t",0)
To construct a 64bit Of 0. For this practice , Let's not talk about userdata The extra cost of , One problem with this is When 64bit Of cdata do table Of key When , Of the same value int64 It's not the same key .
therefore , There is a lighter way to solve int64 The question of support . That is in 64 A platform , We can use it lightuserdata No loss means a int64, By giving lightuserdata Set up metatable , We can take over its data operations . The only drawback is , Compare one int64 And ordinary lua number Is it equal ,lua You can't convert implicitly ( Greater than less than comparison is no problem ).
thus , It took Fengyun a little time to build a library . This library only provides an explicit api , That is to construct a int64 Numbers . It can be downloaded from lua number structure , Also support from a 8 Byte wide string with small header . What is actually stored in memory is a lightuserdata That is, a 64bit The pointer ( So this library is not applicable to 32 Bit platform ). It can also be done through C Interface lua_pushlightuserdata
Let's take one 64bit Integer push on stack .
hold int64 Convert to normal lua number Borrowed # The operator .
边栏推荐
- 新版判断PC和手机端代码,手机端跳转手机端,PC跳转PC端最新有效代码
- Unity修仙手游 | lua动态滑动功能(3种源码具体实现)
- Logo special training camp Section IV importance of font design
- The proofreading activity of data science on the command line second edition was restarted
- Force buckle 3_ 383. Ransom letter
- 【烹饪记录】--- 青椒炒千张
- 测试必会:BUG的分类及推进解决
- In Linux, I call odspcmd to query the database information. How to output silently is to only output values. Don't do this
- Logo Camp d'entraînement section 3 techniques créatives initiales
- The sandbox has reached a cooperation with digital Hollywood to accelerate the economic development of creators through human resource development
猜你喜欢
攻防世界 MISC 进阶区 Erik-Baleog-and-Olaf
30余家机构联合发起数字藏品行业倡议,未来会如何前进?
达梦数据凭什么被称为国产数据库“第一股”?
How to transfer to software testing, one of the high paying jobs in the Internet? (software testing learning roadmap attached)
Locust性能测试 —— 环境搭建及使用
LOGO特训营 第四节 字体设计的重要性
Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
More than 30 institutions jointly launched the digital collection industry initiative. How will it move forward in the future?
Locust performance test - environment construction and use
Google Earth Engine(GEE)——基于 MCD64A1 的 GlobFire 日常火灾数据集
随机推荐
攻防世界 MISC 进阶区 Erik-Baleog-and-Olaf
Logo special training camp section II collocation relationship between words and graphics
我在linux里面 通过调用odspcmd 查询数据库信息 怎么静默输出 就是只输出值 不要这个
阿里推出新品牌“瓴羊”,致力成为“数字化领头羊”
The Sandbox 和数字好莱坞达成合作,通过人力资源开发加速创作者经济的发展
Introduction and application of bigfilter global transaction anti duplication component
攻防世界 misc 高手进阶区 a_good_idea
面试必备 LeetCode 链表算法题汇总,全程干货!
新版判断PC和手机端代码,手机端跳转手机端,PC跳转PC端最新有效代码
MYSQL架构——用户权限与管理
leetcode 72. Edit Distance 编辑距离(中等)
Breakpoint debugging under vs2019 c release
With this PDF, we finally got offers from eight major manufacturers, including Alibaba, bytek and Baidu
高中物理:直线运动
Unity-VScode-Emmylua配置报错解决
MD5 tool class
Alibaba launched a new brand "Lingyang" and is committed to becoming a "digital leader"
SPSS安装激活教程(包含网盘链接)
Li Kou 98: verify binary search tree
idea中pom.xml依赖无法导入