------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real-time scheduling analysis tool. -- This program provides services to automatically check schedulability and -- other performance criteria of real-time architecture models. -- -- Copyright (C) 2002-2016, Frank Singhoff, Alain Plantec, Jerome Legrand -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285 laboratory, Université de Bretagne Occidentale -- -- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008. -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors can be found in AUTHORS.txt and SPONSORS.txt -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ------------------------------------------------------------------------------ -- Last update : -- $Rev: 1249 $ -- $Date: 2014-08-28 07:02:15 +0200 (Fri, 28 Aug 2014) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Text_IO; use Text_IO; with real_util; package body double_util is package double_io is new Text_IO.Float_IO (Double); package double_real is new real_util (Double); function format (f : in Double; after : in Integer := 5) return Unbounded_String is begin return double_real.format (f, after); end format; procedure initialize (f : out Double) is begin f := 0.0; end initialize; procedure put (f : in Double) is begin double_io.Put (f, Exp => 5); end put; procedure put (f : in double_ptr) is begin double_io.Put (f.all, Exp => 5); end put; procedure put_line (f : in Double) is begin double_io.Put (f, Exp => 5); New_Line; end put_line; function equal (num1, num2 : in Double; accuracy : in Integer := 10000) return Boolean is begin return double_real.equal (num1, num2, accuracy); end equal; function double_rem (a : Double; b : Double) return Double is result : Double; begin result := a - Double'Floor (a / b) * b; return (result); end double_rem; function double_mod (a : Double; b : Double) return Double is result : Double; begin result := double'floor(a/b); result := a - b * result; return (result); end double_mod; function copy (obj : double_ptr) return double_ptr is ret : double_ptr; begin ret := new Double; ret.all := obj.all; return ret; end copy; function lcm (a : in double; b : in double) return Double is tmp : constant Double := a * b / (gcd (a, b)); begin return Double'Floor (tmp); end lcm; function gcd (left : double; right : double) return double is min : double:= double'Min (left, right); max : double:= double'Max (left, right); remainder : double; begin reduce : loop if min <= 0.0 then return max; end if; remainder := double_rem(max, min); max := min; min := remainder; end loop reduce; end gcd; end double_util;