20-bit integer math

How to add / subtract / multiply and split integers using only 20 bits instead of 32 bits in C #?

Will these operations be faster than 32-bit precision?

For example, this .NET library has 20 and 30-bit arithmetic at different speeds: http://complex-a5.ru/polyboolean/index.html

Thank.

+3
source share
3 answers

The processors have arithmetic units , so it is very fast to perform operations with 32-bit numbers. This is faster than any code you can write because it is “connected” to the processor.

20- (.. mod 2 ^ 20).

+5

// , 20 32 #?

, 12 32- ints:

int twentyBitSum = (a + b) & 0xFFFFF;

, 32- ?

. , , - .

+2

, , , , 32- , .

, , , 32- , , .

0

Source: https://habr.com/ru/post/1760891/


All Articles