Fix boundary problem in range node (#1338)

* Fix boundary problem in range node

* Remove duplicated test case

* Empty commit to retry Travis CI
This commit is contained in:
Kazuhito Yokoi
2017-07-20 00:42:39 +09:00
committed by Nick O'Leary
parent a40b3dd377
commit c6e453fb00
2 changed files with 6 additions and 6 deletions

View File

@@ -35,8 +35,8 @@ module.exports = function(RED) {
if (n > node.maxin) { n = node.maxin; }
}
if (node.action == "roll") {
if (n >= node.maxin) { n = (n - node.minin) % (node.maxin - node.minin) + node.minin; }
if (n < node.minin) { n = (n - node.minin) % (node.maxin - node.minin) + node.maxin; }
var divisor = node.maxin - node.minin;
n = ((n - node.minin) % divisor + divisor) % divisor + node.minin;
}
msg.payload = ((n - node.minin) / (node.maxin - node.minin) * (node.maxout - node.minout)) + node.minout;
if (node.round) { msg.payload = Math.round(msg.payload); }