1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
8 #ifndef _Common_Real_HH
9 #define _Common_Real_HH
14 // older versions of gcc do not have numeric_limits<double> or it is wrong
15 // and they do not have constants defined by C99 standard
17 static const double REAL_INFINITY = INFINITY;
20 static const double REAL_INFINITY = (DBL_MAX*DBL_MAX);
24 static const double REAL_NAN = NAN;
26 static const double REAL_NAN = (REAL_INFINITY-REAL_INFINITY);
34 * \defgroup Real Real type and related functions
36 * Real type is used to represent those real/float values which will
37 * be used in TITAN run-time environment, in the compiler.
46 /** +/- infinity and not_a_number are non-numeric float values in ttcn-3,
47 these special values cannot be used in some places */
48 bool isSpecialFloatValue(const Real& r);
51 * Converts the Common::Real value to string.
53 * The returned string looks like this:
58 ([\-][1-9]\.(([0-9]+[1-9])|0))
60 ([\-]0\.([0-9]+[1-9]))
73 string Real2string(const Real& r);
75 /** Returns the C++ equivalent of value r */
76 string Real2code(const Real& r);
79 * Converts the string value to Common::Real.
81 Real string2Real(const char *s, const Location& loc);
82 inline Real string2Real(const string& s, const Location& loc)
83 { return string2Real(s.c_str(), loc); }
84 /** @} end of Real group */
88 #endif // _Common_Real_HH