Finite Field Arithmetic

fz_divis.ads


   1 ------------------------------------------------------------------------------
   2 ------------------------------------------------------------------------------
   3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'.               --
   4 --                                                                          --
   5 -- (C) 2019 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 FZ_Type; use FZ_Type;
  21 
  22 
  23 package FZ_Divis is
  24    
  25    pragma Pure;
  26    
  27    -- Dividend is divided by Divisor, producing Quotient and Remainder.
  28    -- WARNING: NO div0 test here! Caller must test.
  29    procedure FZ_IDiv(Dividend  : in  FZ;
  30                      Divisor   : in  FZ;
  31                      Quotient  : out FZ;
  32                      Remainder : out FZ)
  33      with Pre => Dividend'Length = Divisor'Length and
  34      Quotient'Length = Remainder'Length and
  35      Dividend'Length = Quotient'Length;
  36    
  37    -- Exactly same thing as IDiv, but keep only the Quotient
  38    procedure FZ_Div(Dividend  : in FZ;
  39                     Divisor   : in FZ;
  40                     Quotient  : out FZ)
  41      with Pre => Dividend'Length = Divisor'Length and
  42      Dividend'Length = Quotient'Length;
  43    
  44    -- Modulus. Permits the asymmetric Dividend and Divisor in FZ_Mod_Exp.
  45    procedure FZ_Mod(Dividend  : in FZ;
  46                     Divisor   : in FZ;
  47                     Remainder : out FZ)
  48      with Pre => Dividend'Length >= Divisor'Length and
  49      Divisor'Length = Remainder'Length;
  50    
  51 end FZ_Divis;