raw
ffa_ch4_ffacalc.kv      1 ------------------------------------------------------------------------------
ffa_ch4_ffacalc.kv 2 ------------------------------------------------------------------------------
ffa_ch4_ffacalc.kv 3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
ffa_ch4_ffacalc.kv 4 -- --
ffa_ch4_ffacalc.kv 5 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
ffa_ch4_ffacalc.kv 6 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
ffa_ch4_ffacalc.kv 7 -- --
ffa_ch4_ffacalc.kv 8 -- You do not have, nor can you ever acquire the right to use, copy or --
ffa_ch4_ffacalc.kv 9 -- distribute this software ; Should you use this software for any purpose, --
ffa_ch4_ffacalc.kv 10 -- or copy and distribute it to anyone or in any manner, you are breaking --
ffa_ch4_ffacalc.kv 11 -- the laws of whatever soi-disant jurisdiction, and you promise to --
ffa_ch4_ffacalc.kv 12 -- continue doing so for the indefinite future. In any case, please --
ffa_ch4_ffacalc.kv 13 -- always : read and understand any software ; verify any PGP signatures --
ffa_ch4_ffacalc.kv 14 -- that you use - for any purpose. --
ffa_ch4_ffacalc.kv 15 -- --
ffa_ch4_ffacalc.kv 16 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
ffa_ch4_ffacalc.kv 17 ------------------------------------------------------------------------------
ffa_ch4_ffacalc.kv 18 ------------------------------------------------------------------------------
ffa_ch4_ffacalc.kv 19
ffa_ch4_ffacalc.kv 20 package body FZ_Lim is
ffa_ch4_ffacalc.kv 21
ffa_ch4_ffacalc.kv 22 -- Determine if a proposed FFA Bitness is valid.
ffa_ch4_ffacalc.kv 23 function FZ_Valid_Bitness_P(B : in Positive) return Boolean is
ffa_ch4_ffacalc.kv 24 Result : Boolean := False;
ffa_ch4_ffacalc.kv 25 T : Natural := B;
ffa_ch4_ffacalc.kv 26 PopCount : Natural := 0;
ffa_ch4_ffacalc.kv 27 begin
ffa_ch4_ffacalc.kv 28 -- Supposing we meet the minimal bitness:
ffa_ch4_ffacalc.kv 29 if B >= FZ_Minimal_Bitness then
ffa_ch4_ffacalc.kv 30 while T > 0 loop
ffa_ch5_egypt.kv 31 PopCount := PopCount + T mod 2;
ffa_ch4_ffacalc.kv 32 T := T / 2;
ffa_ch4_ffacalc.kv 33 end loop;
ffa_ch4_ffacalc.kv 34
ffa_ch4_ffacalc.kv 35 -- Is B a power of 2?
ffa_ch4_ffacalc.kv 36 if PopCount = 1 then
ffa_ch4_ffacalc.kv 37 Result := True;
ffa_ch4_ffacalc.kv 38 end if;
ffa_ch4_ffacalc.kv 39 end if;
ffa_ch4_ffacalc.kv 40
ffa_ch4_ffacalc.kv 41 return Result;
ffa_ch4_ffacalc.kv 42 end FZ_Valid_Bitness_P;
ffa_ch4_ffacalc.kv 43
ffa_ch4_ffacalc.kv 44 end FZ_Lim;