home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gnat-2.06-src.tgz / tar.out / fsf / gnat / ada / s-vallld.adb < prev    next >
Text File  |  1996-09-28  |  3KB  |  68 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --                       S Y S T E M . V A L _ L L D                        --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.1 $                              --
  10. --                                                                          --
  11. --        Copyright (c) 1992,1993,1994,1995 NYU, All Rights Reserved        --
  12. --                                                                          --
  13. -- The GNAT library is free software; you can redistribute it and/or modify --
  14. -- it under terms of the GNU Library General Public License as published by --
  15. -- the Free Software  Foundation; either version 2, or (at your option) any --
  16. -- later version.  The GNAT library is distributed in the hope that it will --
  17. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  18. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  19. -- Library  General  Public  License for  more  details.  You  should  have --
  20. -- received  a copy of the GNU  Library  General Public License  along with --
  21. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  22. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. with System.Val_Real; use System.Val_Real;
  27.  
  28. package body System.Val_LLD is
  29.  
  30.    ----------------------------
  31.    -- Scan_Long_Long_Decimal --
  32.    ----------------------------
  33.  
  34.    --  We use the floating-point circuit for now, this will be OK on a PC,
  35.    --  but definitely does NOT have the required precision if the longest
  36.    --  float type is IEEE double. This must be fixed in the future ???
  37.  
  38.    function Scan_Long_Long_Decimal
  39.      (Str   : String;
  40.       Ptr   : access Positive'Base;
  41.       Max   : Positive'Base;
  42.       Scale : Integer)
  43.       return  Long_Long_Integer
  44.    is
  45.       Val : Long_Long_Float;
  46.  
  47.    begin
  48.       Val := Scan_Real (Str, Ptr, Max);
  49.       return Long_Long_Integer (Val * 10.0 ** Scale);
  50.    end Scan_Long_Long_Decimal;
  51.  
  52.    -----------------------------
  53.    -- Value_Long_Long_Decimal --
  54.    -----------------------------
  55.  
  56.    --  Again we cheat and use floating-point ???
  57.  
  58.    function Value_Long_Long_Decimal
  59.      (Str   : String;
  60.       Scale : Integer)
  61.       return  Long_Long_Integer
  62.    is
  63.    begin
  64.       return Long_Long_Integer (Value_Real (Str) * 10.0 ** Scale);
  65.    end Value_Long_Long_Decimal;
  66.  
  67. end System.Val_LLD;
  68.