Range node out of bounds?

Hi There,

Just a quick heads up - the range node can be brought to generating values outside of the configured bounds:

[
    {
        "id": "9b95f8806d032b1a",
        "type": "inject",
        "z": "ae38b2dbd23d1681",
        "g": "b4012d193105c803",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "13.1",
        "payloadType": "num",
        "x": 627,
        "y": 1175,
        "wires": [
            [
                "9867b9610c1786d5"
            ]
        ]
    },
    {
        "id": "9867b9610c1786d5",
        "type": "range",
        "z": "ae38b2dbd23d1681",
        "g": "b4012d193105c803",
        "minin": "0",
        "maxin": "9.5",
        "minout": "0",
        "maxout": "100.5",
        "action": "clamp",
        "round": true,
        "property": "payload",
        "name": "",
        "x": 954,
        "y": 1175,
        "wires": [
            [
                "4fbf1055ffadffe5"
            ]
        ]
    }
]

Range node is configured to target range of 0 - 100.5 and the value 13.1 is outside of the incoming range of 0 - 9.5, range node is configured to "limit to the target range".

This example will give a value of 101 because I also set the "round result to the nearest integer".

But the value should really be 100 since that's within the target range.

1 Like

Best place to report bugs is on github directly

1 Like

Btw doing the same test but with negative values works, i.e. target range of 0.5 to 100.5 and using a negative values gives 1 not 0, e.g.:

[{"id":"9d47e88afa90b312","type":"inject","z":"ae38b2dbd23d1681","g":"b4012d193105c803","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"-13.1","payloadType":"num","x":784,"y":1231,"wires":[["a9b9805029fecc58"]]},{"id":"a9b9805029fecc58","type":"range","z":"ae38b2dbd23d1681","g":"b4012d193105c803","minin":"0","maxin":"9.5","minout":"0.5","maxout":"100.5","action":"clamp","round":true,"property":"payload","name":"","x":1121,"y":1231,"wires":[["eb733ddd81f3ed5a"]]}]

but will give zero if the start value is zero.