LCOV - code coverage report
Current view: top level - alma/ASDM - FloatWrapper.cc (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 16 17 94.1 %
Date: 2023-11-06 10:06:49 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * ALMA - Atacama Large Millimeter Array
       3             :  * (c) European Southern Observatory, 2002
       4             :  * (c) Associated Universities Inc., 2002
       5             :  * Copyright by ESO (in the framework of the ALMA collaboration),
       6             :  * Copyright by AUI (in the framework of the ALMA collaboration),
       7             :  * All rights reserved.
       8             :  * 
       9             :  * This library is free software; you can redistribute it and/or
      10             :  * modify it under the terms of the GNU Lesser General Public
      11             :  * License as published by the Free software Foundation; either
      12             :  * version 2.1 of the License, or (at your option) any later version.
      13             :  * 
      14             :  * This library is distributed in the hope that it will be useful,
      15             :  * but WITHOUT ANY WARRANTY, without even the implied warranty of
      16             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17             :  * Lesser General Public License for more details.
      18             :  * 
      19             :  * You should have received a copy of the GNU Lesser General Public
      20             :  * License along with this library; if not, write to the Free Software
      21             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      22             :  * MA 02111-1307  USA
      23             :  *
      24             :  * File Float.cpp
      25             :  */
      26             : 
      27             : #include <alma/ASDM/FloatWrapper.h>
      28             : #include <alma/ASDM/NumberFormatException.h>
      29             : 
      30             : #include <sstream>
      31             : 
      32             : #include <iostream>
      33             : using namespace std;
      34             : 
      35             : namespace asdm {
      36             : 
      37             :     const float Float::MAX_VALUE = 3.4028235e+38f;
      38             :     const float Float::MIN_VALUE = 1.4e-45f;
      39             : 
      40       54907 :         float Float::parseFloat(const string &s) {
      41       54907 :                 istringstream in;
      42       54907 :                 in.str(s);
      43             :                 float x;
      44       54907 :                 in >> x;
      45       54907 :                 if (in.rdstate() == istream::failbit)
      46           0 :                         throw NumberFormatException (s);
      47      109814 :                 return x;
      48             :         }
      49             : 
      50        1033 :         string Float::toString(float x) {
      51        2066 :                 ostringstream out;
      52        1033 :                 out.width(20);
      53        1033 :                 out.precision(12);
      54        1033 :                 out << x;
      55        2066 :                 string s = out.str();
      56        1033 :                 int i = 0;
      57       20660 :                 while (i < 20 && s.at(i) == ' ')
      58       19627 :                         ++i;
      59        2066 :                 return s.substr(i,s.length() - i);
      60             :         }
      61             : 
      62             : } // End namespace.

Generated by: LCOV version 1.16