Ad Widget

Collapse

calculated item without if

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bricka
    Junior Member
    • Jun 2018
    • 23

    #1

    calculated item without if

    Hello

    I need to implement function:
    if xx>32767
    then xx = 65535-xx


    I'm taking xx with modbus. There must be values between -32767 and 32767. But the controller can't give negative value - only 0...65535
    So I need to recalculate it.

    Thank's for advice.
  • Linwood
    Senior Member
    • Dec 2013
    • 398

    #2
    You can use conditionals as 1 and 0, so something like x * (x<=32767) + (65535 - x) * (x> 32767) might do it, if a bit ugly.

    Comment

    • bricka
      Junior Member
      • Jun 2018
      • 23

      #3
      Originally posted by Linwood
      You can use conditionals as 1 and 0, so something like x * (x<=32767) + (65535 - x) * (x> 32767) might do it, if a bit ugly.

      Thank's.
      Works great... just x * (x<=32767) + ( x- 65535) * (x> 32767)

      Comment

      Working...