# Any negative number should be zero

**URL:** <https://discourse.nodered.org/t/any-negative-number-should-be-zero/62577>\
**Category:** General\
**Tags:** function-node\
**Created:** [13 May 2022 05:28 UTC](https://discourse.nodered.org/t/any-negative-number-should-be-zero/62577 "2022-05-13T05:28:34Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![hobbes1069](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hobbes1069/32/39892_2.png) [@hobbes1069](https://discourse.nodered.org/u/hobbes1069)\
**Post date:** [18 May 2022 11:44 UTC](https://discourse.nodered.org/t/any-negative-number-should-be-zero/62577/21 "2022-05-18T11:44:09Z")

</div>

Looks like you got it sorted. My random idea was to square it since the square of a negative number will be positive 🙂

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [18 May 2022 12:25 UTC](https://discourse.nodered.org/t/any-negative-number-should-be-zero/62577/22 "2022-05-18T12:25:21Z")

</div>

If you also know the maximum (or can guess one) - you can always just use a range node set to limit the range to the target range eg

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/e/fec3ff0f2860bf9e01128cc6097638607356bc0c.png)\

That way anything outside will be clamped to the min (and max) values...

---

<div class="post-metadata">

**Author:** ![9toejack](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9toejack/32/56868_2.png) [@9toejack](https://discourse.nodered.org/u/9toejack)\
**Post date:** [18 May 2022 14:56 UTC](https://discourse.nodered.org/t/any-negative-number-should-be-zero/62577/23 "2022-05-18T14:56:17Z")

</div>

@dceejay that will work for the psi for my fermenters, but not for inside functions when also using the psi data to calculate the volume of the boil kettle.  
I did screen shot that on cell phone and added it to my project folder for further reference. Cheers

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 June 2022 14:57 UTC](https://discourse.nodered.org/t/any-negative-number-should-be-zero/62577/24 "2022-06-01T14:57:11Z")

</div>

Closed on 1 June 2022 14:57 UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/any-negative-number-should-be-zero/62577.md?page=1)
