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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include "StdDefs.h"
24 
25 
26 // set by option --precision (see SystemFrame.cpp)
27 int gPrecision = 2;
28 int gPrecisionGeo = 6;
29 bool gHumanReadableTime = false;
30 bool gSimulation = false;
31 
32 bool gDebugFlag1 = false;
33 bool gDebugFlag2 = false;
34 bool gDebugFlag3 = false;
35 bool gDebugFlag4 = false;
36 
37 double truncate(double x, int fractionBits) {
38  return ceil(x * (1 << fractionBits)) / (1 << fractionBits);
39 }
40 
41 double roundBits(double x, int fractionBits) {
42  const double x2 = x * (1 << fractionBits);
43  const double rounded = x2 < 0 ? ceil(x2 - 0.5) : floor(x2 + 0.5);
44  return rounded / (1 << fractionBits);
45 }
46 
47 /****************************************************************************/
48 
bool gDebugFlag1
global utility flags for debugging
Definition: StdDefs.cpp:32
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:27
bool gDebugFlag3
Definition: StdDefs.cpp:34
bool gSimulation
Definition: StdDefs.cpp:30
int gPrecisionGeo
Definition: StdDefs.cpp:28
bool gDebugFlag4
Definition: StdDefs.cpp:35
double roundBits(double x, int fractionBits)
round to the given number of mantissa bits beyond the given number
Definition: StdDefs.cpp:41
bool gHumanReadableTime
Definition: StdDefs.cpp:29
double truncate(double x, int fractionBits)
discrds mantissa bits beyond the given number
Definition: StdDefs.cpp:37
bool gDebugFlag2
Definition: StdDefs.cpp:33