-
+ F6117D2B425E46E65421ABDAB29FDB3EE664B657B36930A8249EC3E4983BE09258CA4BD6B24C0B81050623C39F58BF6B2EEABDA579A2066176F439D664CD2053
ffa/libffa/fz_lim.adb
(0 . 0)(1 . 46)
1001 ------------------------------------------------------------------------------
1002 ------------------------------------------------------------------------------
1003 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
1004 -- --
1005 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
1006 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
1007 -- --
1008 -- You do not have, nor can you ever acquire the right to use, copy or --
1009 -- distribute this software ; Should you use this software for any purpose, --
1010 -- or copy and distribute it to anyone or in any manner, you are breaking --
1011 -- the laws of whatever soi-disant jurisdiction, and you promise to --
1012 -- continue doing so for the indefinite future. In any case, please --
1013 -- always : read and understand any software ; verify any PGP signatures --
1014 -- that you use - for any purpose. --
1015 -- --
1016 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
1017 ------------------------------------------------------------------------------
1018 ------------------------------------------------------------------------------
1019
1020 package body FZ_Lim is
1021
1022 -- Determine if a proposed FFA Bitness is valid.
1023 function FZ_Valid_Bitness_P(B : in Positive) return Boolean is
1024 Result : Boolean := False;
1025 T : Natural := B;
1026 PopCount : Natural := 0;
1027 begin
1028 -- Supposing we meet the minimal bitness:
1029 if B >= FZ_Minimal_Bitness then
1030 while T > 0 loop
1031 if T mod 2 = 1 then
1032 PopCount := PopCount + 1;
1033 end if;
1034 T := T / 2;
1035 end loop;
1036
1037 -- Is B a power of 2?
1038 if PopCount = 1 then
1039 Result := True;
1040 end if;
1041 end if;
1042
1043 return Result;
1044 end FZ_Valid_Bitness_P;
1045
1046 end FZ_Lim;