1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel math math.functions ;
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 ;