1-- Copyright 2004, 2007, 2008, 2009, 2010, 2011 2-- Free Software Foundation, Inc. 3-- 4-- This program is free software; you can redistribute it and/or modify 5-- it under the terms of the GNU General Public License as published by 6-- the Free Software Foundation; either version 3 of the License, or 7-- (at your option) any later version. 8-- 9-- This program is distributed in the hope that it will be useful, 10-- but WITHOUT ANY WARRANTY; without even the implied warranty of 11-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12-- GNU General Public License for more details. 13-- 14-- You should have received a copy of the GNU General Public License 15-- along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17with System; 18 19procedure Fixed_Points is 20 21 ------------ 22 -- Test 1 -- 23 ------------ 24 25 -- Fixed point subtypes 26 27 type Base_Fixed_Point_Type is 28 delta 1.0 / 16.0 29 range (System.Min_Int / 2) * 1.0 / 16.0 .. 30 (System.Max_Int / 2) * 1.0 / 16.0; 31 32 subtype Fixed_Point_Subtype is 33 Base_Fixed_Point_Type range -50.0 .. 50.0; 34 35 type New_Fixed_Point_Type is 36 new Base_Fixed_Point_Type range -50.0 .. 50.0; 37 38 Base_Object : Base_Fixed_Point_Type := -50.0; 39 Subtype_Object : Fixed_Point_Subtype := -50.0; 40 New_Type_Object : New_Fixed_Point_Type := -50.0; 41 42 43 ------------ 44 -- Test 2 -- 45 ------------ 46 47 -- Overprecise delta 48 49 Overprecise_Delta : constant := 0.135791357913579; 50 -- delta whose significant figures cannot be stored into a long. 51 52 type Overprecise_Fixed_Point is 53 delta Overprecise_Delta range 0.0 .. 200.0; 54 for Overprecise_Fixed_Point'Small use Overprecise_Delta; 55 56 Overprecise_Object : Overprecise_Fixed_Point := 57 Overprecise_Fixed_Point'Small; 58 59begin 60 Base_Object := 1.0/16.0; -- Set breakpoint here 61 Subtype_Object := 1.0/16.0; 62 New_Type_Object := 1.0/16.0; 63 Overprecise_Object := Overprecise_Fixed_Point'Small * 2; 64end Fixed_Points; 65