#include "StdDefs.h"
#include <sstream>
int gPrecision = 2;
int gPrecisionEmissions = 2;
int gPrecisionGeo = 6;
int gPrecisionRandom = 4;
bool gHumanReadableTime = false;
bool gSimulation = false;
bool gIgnoreUnknownVClass = false;
bool gLocaleInitialized = false;
double gWeightsRandomFactor = 1;
double gWeightsWalkOppositeFactor = 1;
bool gRoutingPreferences = false;
std::string gLanguage = "C";
int GUIDesignHeight = 23;
int GUIDesignDialogButtonsHeight = 32;
bool gDebugFlag1 = false;
bool gDebugFlag2 = false;
bool gDebugFlag3 = false;
bool gDebugFlag4 = false;
bool gDebugFlag5 = false;
bool gDebugFlag6 = false;
double truncate(double x, int fractionBits) {
return ceil(x * (1 << fractionBits)) / (1 << fractionBits);
}
double roundBits(double x, int fractionBits) {
const double x2 = x * (1 << fractionBits);
const double rounded = x2 < 0 ? ceil(x2 - 0.5) : floor(x2 + 0.5);
return rounded / (1 << fractionBits);
}
double roundDecimal(double x, int precision) {
const double p = pow(10, precision);
const double x2 = x * p;
return (x2 < 0 ? ceil(x2 - 0.5) : floor(x2 + 0.5)) / p;
}
double roundDecimalToEven(double x, int precision) {
const int p = (int)pow(10, precision);
return std::nearbyint(x * p) / p;
}
int
getScalingQuota(double frac, long long int loaded) {
if (frac < 0 || frac == 1.) {
return 1;
}
const int base = (int)frac;
const int resolution = 1000;
const int intFrac = (int)floor((frac - base) * resolution + 0.5);
if (((loaded % resolution) * intFrac) % resolution < intFrac) {
return base + 1;
}
return base;
}