Jump to content
View in the app

A better way to browse. Learn more.

Universal Devices Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Arithmetic calculations

Featured Replies

Posted

How do I perform simple arithmetic on several integer variables with the result assigned to a new variable?  For example:

$TempGradient = $inside temp - $ outside temp

Solved by paulbates

Go to solution

Results are always assigned to the variable register they originate from.

Try not to use STATE variables for complex calculations as they may trigger your dependent programs repeatedly with premature results. For multiple operation calculations, it may be best to use an Integer variable and then transfer the resultant into the STATE variable.

Use of a lower precision variable, during calculations,  will result in truncated decimal places for the final variable precision regardless of the final variable set precision.

  • Author

Hmmm.  I looked at the ISY manual but it's not clear.  I am using integer variables. in a program, I assign an integer variable (X) the result of a sensor temperature outside the house.  In the same program, I assign a second variable (Y) the result of a temperature  inside the house from a separate sensor (thermostat).  What I want to do is get the difference between the 2 variables (Y -X) and assign that to a third integer variable (Z).  Then, if the difference is greater than 15 degrees F, the program turns the furnace on.  

  • Solution

It will take to statements to get the total in the variable:

$TempGradient = $inside temp
$TempGradient -= $outside temp

The -= means subtract $outside temp from $Tempgradient.

$Tempgradient has to be a state variable, as is any variable that is used in an If statement

Edited by paulbates

Guest
This topic is now closed to further replies.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.