简体   繁体   中英

how to modulo int64 by avx

I want to implement 5%3=2 by avx.

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.

how to solve overflow when convert int64 to 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.

'long double' type would be suitable, but it's only avaliable with x87, not SIMD.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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