Random node always returns floating point

This commit is contained in:
Nick O'Leary 2015-04-22 13:18:55 +01:00
parent 2de7a46bb9
commit e41893eccb
2 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-random",
"version" : "0.0.2",
"version" : "0.0.3",
"description" : "A Node-RED node that that when triggered generates a random number between two values.",
"dependencies" : {
},

View File

@ -1,5 +1,5 @@
/**
* Copyright 2014 IBM Corp.
* Copyright 2014, 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,7 +23,7 @@ module.exports = function(RED) {
this.inte = n.inte || false;
var node = this;
this.on("input", function(msg) {
if (node.inte === true) {
if (node.inte == "true" || node.inte === true) {
msg.payload = Math.round(Number(Math.random()) * (node.high - node.low + 1) + node.low - 0.5);
} else {
msg.payload = Number(Math.random()) * (node.high - node.low) + node.low;