]> gitweb.factorcode.org Git - factor.git/blob - extra/crypto/barrett/barrett.factor
Delete empty unit tests files, remove 1- and 1+, reorder IN: lines in a lot of places...
[factor.git] / extra / crypto / barrett / barrett.factor
1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel math math.functions ;
4 IN: crypto.barrett
5
6 : barrett-mu ( n size -- mu )
7     #! Calculates Barrett's reduction parameter mu
8     #! size = word size in bits (8, 16, 32, 64, ...)
9     [ [ log2 1 + ] [ / 2 * ] bi* ]
10     [ 2^ rot ^ swap /i ] 2bi ;