Eclipse SUMO - Simulation of Urban MObility
StdDefs.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2014-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 /****************************************************************************/
21 #include "StdDefs.h"
22 
23 
24 // set by option --precision (see SystemFrame.cpp)
25 int gPrecision = 2;
26 int gPrecisionGeo = 6;
27 bool gHumanReadableTime = false;
28 bool gSimulation = false;
30 
31 bool gDebugFlag1 = false;
32 bool gDebugFlag2 = false;
33 bool gDebugFlag3 = false;
34 bool gDebugFlag4 = false;
35 
36 double truncate(double x, int fractionBits) {
37  return ceil(x * (1 << fractionBits)) / (1 << fractionBits);
38 }
39 
40 double roundBits(double x, int fractionBits) {
41  const double x2 = x * (1 << fractionBits);
42  const double rounded = x2 < 0 ? ceil(x2 - 0.5) : floor(x2 + 0.5);
43  return rounded / (1 << fractionBits);
44 }
45 
46 
47 /****************************************************************************/
double truncate(double x, int fractionBits)
discrds mantissa bits beyond the given number
Definition: StdDefs.cpp:36
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:25
bool gDebugFlag3
Definition: StdDefs.cpp:33
double gWeightsRandomFactor
Definition: StdDefs.cpp:29
double roundBits(double x, int fractionBits)
round to the given number of mantissa bits beyond the given number
Definition: StdDefs.cpp:40
bool gSimulation
Definition: StdDefs.cpp:28
bool gDebugFlag2
Definition: StdDefs.cpp:32
bool gHumanReadableTime
Definition: StdDefs.cpp:27
bool gDebugFlag4
Definition: StdDefs.cpp:34
bool gDebugFlag1
global utility flags for debugging
Definition: StdDefs.cpp:31
int gPrecisionGeo
Definition: StdDefs.cpp:26