summaryrefslogtreecommitdiff
path: root/node/Utils.hpp
diff options
context:
space:
mode:
authorJoseph Henry <josephjah@gmail.com>2018-05-30 17:45:29 -0700
committerJoseph Henry <josephjah@gmail.com>2018-05-30 17:45:29 -0700
commit46a7a2be2e1c4d09d1da2bf26b110a31ec3d0661 (patch)
tree6b75b8e7f5868264428ff3b158a8c1b27288e122 /node/Utils.hpp
parent8199dbd0dcbc3259eb3218ece183315eddb1e84b (diff)
downloadinfinitytier-46a7a2be2e1c4d09d1da2bf26b110a31ec3d0661.tar.gz
infinitytier-46a7a2be2e1c4d09d1da2bf26b110a31ec3d0661.zip
Added VERB_ACK and VERB_QOS_MEASUREMENT, refined notion of path quality
Diffstat (limited to 'node/Utils.hpp')
-rw-r--r--node/Utils.hpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/node/Utils.hpp b/node/Utils.hpp
index a24f2c9a..6ce67328 100644
--- a/node/Utils.hpp
+++ b/node/Utils.hpp
@@ -261,6 +261,14 @@ public:
return l;
}
+ static inline float normalize(float value, int64_t bigMin, int64_t bigMax, int32_t targetMin, int32_t targetMax)
+ {
+ int64_t bigSpan = bigMax - bigMin;
+ int64_t smallSpan = targetMax - targetMin;
+ float valueScaled = (value - (float)bigMin) / (float)bigSpan;
+ return (float)targetMin + valueScaled * (float)smallSpan;
+ }
+
/**
* Generate secure random bytes
*