Skip to main content
September 10, 2013
Answered

Capping math calculation at zero?

  • September 10, 2013
  • 1 reply
  • 767 views

Hi guys

How do you cap a maths calc so that if it's capped at zero if the result was going to be negative? Is there a func?

Cheers

This topic has been closed for replies.
Correct answer kglad

:

yourcalculatedvalue = Math.max(0,yourcalculatedvalue)

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
September 10, 2013

:

yourcalculatedvalue = Math.max(0,yourcalculatedvalue)

September 11, 2013

Thanks kglad - I'll slot that in today.

kglad
Community Expert
Community Expert
September 11, 2013

you're welcome.