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-2019 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 /****************************************************************************/
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include "StdDefs.h"
23 
24 
25 // set by option --precision (see SystemFrame.cpp)
26 int gPrecision = 2;
27 int gPrecisionGeo = 6;
28 bool gHumanReadableTime = false;
29 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 
roundBits
double roundBits(double x, int fractionBits)
round to the given number of mantissa bits beyond the given number
Definition: StdDefs.cpp:41
gSimulation
bool gSimulation
Definition: StdDefs.cpp:29
gPrecisionGeo
int gPrecisionGeo
Definition: StdDefs.cpp:27
gWeightsRandomFactor
double gWeightsRandomFactor
Definition: StdDefs.cpp:30
gDebugFlag3
bool gDebugFlag3
Definition: StdDefs.cpp:34
truncate
double truncate(double x, int fractionBits)
discrds mantissa bits beyond the given number
Definition: StdDefs.cpp:37
gHumanReadableTime
bool gHumanReadableTime
Definition: StdDefs.cpp:28
gDebugFlag4
bool gDebugFlag4
Definition: StdDefs.cpp:35
gDebugFlag2
bool gDebugFlag2
Definition: StdDefs.cpp:33
gDebugFlag1
bool gDebugFlag1
global utility flags for debugging
Definition: StdDefs.cpp:32
gPrecision
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:26
StdDefs.h