mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Random node always returns floating point
This commit is contained in:
parent
2de7a46bb9
commit
e41893eccb
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-random",
|
"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.",
|
"description" : "A Node-RED node that that when triggered generates a random number between two values.",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2014 IBM Corp.
|
* Copyright 2014, 2015 IBM Corp.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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;
|
this.inte = n.inte || false;
|
||||||
var node = this;
|
var node = this;
|
||||||
this.on("input", function(msg) {
|
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);
|
msg.payload = Math.round(Number(Math.random()) * (node.high - node.low + 1) + node.low - 0.5);
|
||||||
} else {
|
} else {
|
||||||
msg.payload = Number(Math.random()) * (node.high - node.low) + node.low;
|
msg.payload = Number(Math.random()) * (node.high - node.low) + node.low;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user