简体   繁体   English

如何通过avx取模int64

[英]how to modulo int64 by avx

I want to implement 5%3=2 by avx.我想通过avx实现5%3=2。

normal: int64 x = a % b

math: int64 x = a-((double)a/b)*b

avx:
__m256 tmp1 = _mm256_cvtepi32_ps(data);

I need convert a big number from int64 to float, then float overflow.我需要将一个大数字从 int64 转换为浮点数,然后浮点数溢出。

how to solve overflow when convert int64 to float? int64转float时溢出如何解决?

In common case your way is wrong.通常情况下你的方式是错误的。 'double' type has 52-bit mantissa which obviously isn't sufficient to represent exactly an arbitrary 64-bit integer. You might get wrong results. 'double' 类型有 52 位尾数,这显然不足以准确表示任意 64 位 integer。您可能会得到错误的结果。

'long double' type would be suitable, but it's only avaliable with x87, not SIMD. 'long double' 类型比较合适,但它仅适用于 x87,不适用于 SIMD。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM