1 /******************************************************************************
2 * Copyright (c) 2000-2016 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
14 * Szabo, Janos Zoltan – initial implementation
16 ******************************************************************************/
17 #ifndef _Common_Real_HH
18 #define _Common_Real_HH
23 // older versions of gcc do not have numeric_limits<double> or it is wrong
24 // and they do not have constants defined by C99 standard
26 static const double REAL_INFINITY = INFINITY;
29 static const double REAL_INFINITY = (DBL_MAX*DBL_MAX);
33 static const double REAL_NAN = NAN;
35 static const double REAL_NAN = (REAL_INFINITY-REAL_INFINITY);
43 * \defgroup Real Real type and related functions
45 * Real type is used to represent those real/float values which will
46 * be used in TITAN run-time environment, in the compiler.
55 /** +/- infinity and not_a_number are non-numeric float values in ttcn-3,
56 these special values cannot be used in some places */
57 bool isSpecialFloatValue(const Real& r);
60 * Converts the Common::Real value to string.
62 * The returned string looks like this:
67 ([\-][1-9]\.(([0-9]+[1-9])|0))
69 ([\-]0\.([0-9]+[1-9]))
82 string Real2string(const Real& r);
84 /** Returns the C++ equivalent of value r */
85 string Real2code(const Real& r);
88 * Converts the string value to Common::Real.
90 Real string2Real(const char *s, const Location& loc);
91 inline Real string2Real(const string& s, const Location& loc)
92 { return string2Real(s.c_str(), loc); }
93 /** @} end of Real group */
97 #endif // _Common_Real_HH