fixed_points.adb 2.1 KB

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