From: Jérôme Benoit Date: Tue, 21 Sep 2021 16:29:42 +0000 (+0200) Subject: Fix negative values in meter values X-Git-Tag: v1.1.5~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=87f1fc2acc3bfc56decd07366b6dc9466b4e267e;p=e-mobility-charging-stations-simulator.git Fix negative values in meter values Signed-off-by: Jérôme Benoit --- diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 3782beeb..92373cf0 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -104,7 +104,7 @@ export default class Utils { throw new RangeError('Invalid interval'); } const randomPositiveFloat = crypto.randomBytes(4).readUInt32LE() / 0xffffffff; - const sign = (negative && randomPositiveFloat < 0.5) ? 1 : -1; + const sign = (negative && randomPositiveFloat < 0.5) ? -1 : 1; return sign * (randomPositiveFloat * (max - min) + min); }