File : w_pred.adb


   1 ------------------------------------------------------------------------------
   2 ------------------------------------------------------------------------------
   3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'.               --
   4 --                                                                          --
   5 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org )                      --
   6 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html     --
   7 --                                                                          --
   8 -- You do not have, nor can you ever acquire the right to use, copy or      --
   9 -- distribute this software ; Should you use this software for any purpose, --
  10 -- or copy and distribute it to anyone or in any manner, you are breaking   --
  11 -- the laws of whatever soi-disant jurisdiction, and you promise to         --
  12 -- continue doing so for the indefinite future. In any case, please         --
  13 -- always : read and understand any software ; verify any PGP signatures    --
  14 -- that you use - for any purpose.                                          --
  15 --                                                                          --
  16 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm .     --
  17 ------------------------------------------------------------------------------
  18 ------------------------------------------------------------------------------
  19 
  20 with Word_Ops; use Word_Ops;
  21 
  22 -- Elementary Predicates on Words:
  23 package body W_Pred is
  24    
  25    -- Return 1 if N is equal to 0; otherwise return 0.
  26    function W_ZeroP(N : in Word) return WBool is
  27    begin
  28       return W_Borrow(N, 1, N - 1);
  29    end W_ZeroP;
  30    
  31    
  32    -- Return 1 if N is unequal to 0; otherwise return 0.
  33    function W_NZeroP(N : in Word) return WBool is
  34    begin
  35       return 1 xor W_ZeroP(N);
  36    end W_NZeroP;
  37    
  38    
  39    -- Return WBool-complement of N.
  40    function W_Not(N : in WBool) return WBool is
  41    begin
  42       return 1 xor N;
  43    end W_Not;
  44    
  45    
  46    -- Return 1 if N is odd; otherwise return 0.
  47    function W_OddP(N : in Word) return WBool is
  48    begin
  49       return 1 and N;
  50    end W_OddP;
  51    
  52    
  53    -- Return 1 if A is equal to B ; otherwise return 0.
  54    function W_EqP(A : in Word; B : in Word) return WBool is
  55    begin
  56       return W_ZeroP(A xor B);
  57    end W_EqP;
  58    
  59 end W_Pred;