sqlite c++ and unsigned int key
sqlite c++ and unsigned int key
我正在尝试迁移到SQLite。在我的C++程序中,我使用unsigned int key
来存储id。当我将数据从C++程序序列化到SQLite,然后将其反序列化或浏览数据库时,我会在列中看到负值(带符号)。
我在序列化时使用以下函数绑定unsigned ints
:
sqlite3_bind_int(stmt, 1, key);
键的表列在创建时声明为INT
。也许这是我的错误?
有什么建议可以正确地将unsigned ints
序列化到SQLite中并在没有更改的情况下加载回来?
SQLite的类型系统不支持无符号整数。但是您可以使用sqlite3_bind_int64
:unsigned int
(假设它是32位的)可以无损地转换为int64_t
。
相关文章:
- 为什么在全局范围内使用"extern int a"似乎不行?
- int(c) 和 c-'0' 之间的区别。C++
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 为什么野牛仍在使用"int yylex(void)",却找不到"int yylex(YYS
- 有符号的int和int-有没有一种方法可以在C++中区分它们
- 请解释这句话(cout<<1+int((a<b)^((b-a)&1) )<<endl
- 是否可以从int转换为enum类类型
- 不能在初始值设定项列表中将非常量表达式从类型 'int' 缩小到'unsigned long long'
- 向量 <int> a {N, 0} 和 int arr a[N] = {0} 的时间复杂度有什么区别
- 'short int'持有的值溢出,但"自动"不会溢出?
- 如何在C++中将一个无符号的 int 转换为两个无符号的短裤?
- 调用'begin(int [n])'没有匹配函数
- 没有显式声明的int[]中的foreach
- 在c++中访问int到类对象的映射时出错
- map(long long int,long long int)不适用于key=1000 000 000(在long l
- 将链表的头部传递给函数时。为什么我们需要通过引用来传递它,例如在 push(node* &head, int key)
- 当 wordCount 中不存在键时,我应该对 unordered_map<string, int> 使用 ++wordCount[key] 吗?
- sqlite c++ and unsigned int key
- 在c++中映射,key作为字符串,int作为值
- 将keycode的字符串表示形式转换为Qt::Key(或任何int)并返回