Home > Expression Editor, Tips > Integer math the easy way?

Integer math the easy way?

October 21, 2010 Leave a comment Go to comments

Perhaps this is well-known to many Visual Basic programmers, but today I learned about a quirky way of using the division symbol. Specifically, if you need to perform integer math in a ROCLINK 800 custom user display expression, this might be handy. See below…

Notice how I used the forward slash to perform floating-point division. Next, look how using the back slash changes the result…

If I hadn’t pointed this out, would you have noticed?

The downside I see right away to using this method is during debugging. Your peers might gloss over your cleverness and suspect the bug is elsewhere (or, if you’re like me … the next day I would probably have forgotten). Therefore, I suggest liberal use of code comments.

Categories: Expression Editor, Tips
  1. Joshua S
    December 7, 2012 at 8:07 PM

    Hello, I’m trying to build a user display. I want to utilize a single button that will write two individual values to two individual byte registers at the same time the button is pressed. Does anyone know a expression that will perform this action? Thanks in advance!

  1. No trackbacks yet.

Leave a comment