-
Hi, I am curious why we have the following implementation for the mean over FP: Line 59 in b8d2d5d Is that because it's faster to divide a secret number by a power of two rather than by some general number? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It's to prevent (unnecessary) loss of precision in the division by the public integer |
Beta Was this translation helpful? Give feedback.
It's to prevent (unnecessary) loss of precision in the division by the public integer
n
. If we simply divide byn
, which works out as multiplying by1/n
, we get a fixed-point number of the form0.00001***
say, in binary, with a lot of leading zeros and few significant bits. Therefore, we shift this to the left to make it of the form0.1*******
, which represents1/n
with more significant bits. The product with the sums
is shifted back at the end. Note thate = n.bit_length()-1
to ensure1/2 < 2**e / n <= 1
as written in the comment on line 58.