sql - PostgreSQL 中数字之间的异或

标签 sql postgresql integer biginteger unsigned

所以我有两个整数 > 2 ^ 63 - 1 但 < 2 ^ 64 -1。在大多数语言中这是 BIGINT UNSIGNED,但根据 Comparison of database column types in MySQL, PostgreSQL, and SQLite? (Cross-Mapping) ,它在 postogresql 中是 numeric(20)

问题是,当我尝试在两个未签名的 bigints 之间执行 postgresql 异或运算时:

select 17418945696623429624::numeric(20) # 17418945696623429624::numeric(20);

=>

ERROR:  operator does not exist: numeric # numeric

对于任何小于 2 ^ 63 -1 的非“数字”整数,它都可以正常工作。

换句话说:如何在大于 2 ^ 63 - 1 但小于 2 ^ 64 - 1 的两个数字之间执行 XOR 运算?前任。我如何在 PostgreSQL 中将 17418945696623429624 与自身异或?

最佳答案

看起来像PostgreSQL has a bigint type -- 你为什么不使用它?

关于sql - PostgreSQL 中数字之间的异或,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5463950/

相关文章:

c - 如何在 C 中使用 write() 函数写入整数?

java - 关于保存数据的hsql问题

sql - 获取 SQL 中连续日期列表之间的平均时间

node.js - 在 Postgres 中使用审计表为 NOTIFY/LISTEN 创建触发器是个好主意吗?

postgresql - OpenLayers 中的矢量投影

r - 使用 DBI 包连接到 PostgreSQL 时在 R 中不同

algorithm - 重复模式中的整数分解

python - 如何在 Python 中将字符串转换为十六进制整数?

PHP mysql 数据库两个同时请求同一个表

mysql - 存储大量数据的更好方法?