有没有全一点的 int128 注意事项

学术版

Light_az @ 2024-11-28 19:09:17

Rt ,网上找到的断断续续,没有全面介绍的,Cu


by xiezheyuan @ 2024-11-28 19:42:51

@CodingOIer 我好像就是GCC 9 哈

xiezheyuan ➜ ~ $ g++ --version
g++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

xiezheyuan ➜ ~ $ gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

by CodingOIer @ 2024-11-28 19:43:24

@xiezheyuan尽管不会炸也不建议使用 int128 像正常地类型一样用,毕竟不是标准里的东西

他告诉你 1 + 1 = 3 实际上也是符合 C++ 标准地


by CodingOIer @ 2024-11-28 19:43:57

@xiezheyuan我也没炸


by litjohn @ 2024-11-28 20:26:38

@CodingOIer 你会发现它的加法/位运算需要两条指令,乘法需要5条指令,除法需要7条指令


by CodingOIer @ 2024-11-28 20:28:02

@litjohn?没看懂


by litjohn @ 2024-11-28 20:29:49

@CodingOIer 观察汇编,发现在不用simd的情况下__int128的算术运算需要比 long long 更多的指令,时间常数会很大。


by CodingOIer @ 2024-11-28 20:31:12

@litjohn1,所以不建议使用


上一页 |