当前位置:网站首页>[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 .
边栏推荐
- Breakpoint debugging under vs2019 c release
- 攻防世界 MISC 高手进阶区 001 normal_png
- 30余家机构联合发起数字藏品行业倡议,未来会如何前进?
- Shell script implements application service log warehousing MySQL
- How to transfer to software testing, one of the high paying jobs in the Internet? (software testing learning roadmap attached)
- Force buckle 3_ 383. Ransom letter
- PHP short video source code, thumb animation will float when you like it
- Concurrent network modular reading notes transfer
- Test will: bug classification and promotion solution
- Erik baleog and Olaf, advanced area of misc in the attack and defense world
猜你喜欢
攻防世界 MISC 进阶区 Ditf
攻防世界 MISC 进阶区 hit-the-core
Unity修仙手游 | lua动态滑动功能(3种源码具体实现)
共创软硬件协同生态:Graphcore IPU与百度飞桨的“联合提交”亮相MLPerf
LOGO特訓營 第一節 鑒別Logo與Logo設計思路
Ascendex launched Walken (WLKN) - an excellent and leading "walk to earn" game
Concurrent network modular reading notes transfer
NFT Insider #64:电商巨头eBay提交NFT相关商标申请,毕马威将在Web3和元宇宙中投入3000万美元
Naacl-22 | introduce the setting of migration learning on the prompt based text generation task
Locust性能测试 —— 环境搭建及使用
随机推荐
Logo special training camp section III initial creative techniques
Attack and defense world misc advanced area Hong
记录:关于Win10系统中Microsoft Edge上的网页如何滚动截屏?
MySQL storage data encryption
SQL中MAX与GREATEST的区别
Easy to use app recommendation: scan QR code, scan barcode and view history
Introduction and application of bigfilter global transaction anti duplication component
leetcode 72. Edit distance edit distance (medium)
2022-07-04:以下go语言代码输出什么?A:true;B:false;C:编译错误。 package main import “fmt“ func main() { fmt.Pri
Google Earth Engine(GEE)——以MODIS/006/MCD19A2为例批量下载逐天AOD数据逐天的均值、最大值、最小值、标准差、方差统计分析和CSV下载(北京市各区为例)
BigFilter全局交易防重组件的介绍与应用
啃下大骨头——排序(二)
leetcode 72. Edit distance edit distance (medium)
odps 中 对表进行了一次备份,为什么在元数据库查m_table 时,两张表的逻辑大小不一致,但数
Postgresqlql advanced skills pivot table
How to manage 15million employees easily?
Flask 上下文详解
Concurrent network modular reading notes transfer
Hit the core in the advanced area of misc in the attack and defense world
Logo special training camp section II collocation relationship between words and graphics