# Combining INT16 Values

## Recommended Posts

Hi forum goers.  I would like to combine two values from two separate INT16 registers into a single INT16 register without adding or subtracting them.

For example:

INT16-1 contains the value "34"

INT16-2 contains the value "56"

I'd like INT16-3 to contain "3456"

Is this possible and if so, can you show me the way.

Thanks!

Michael

##### Share on other sites

This is not always possible (since the result might exceed the limit of INT16, for example:

Int16-1: 123

Int16-2: 456

You will get 123456, while the limit of Int16 is 32787 (and uint16 is 65535).

As for the math, count the number of digits in the right number (the lowest part), if it has 2 digits, then it means that you need to multiply the higher number by 10^2 (which is 100), so you get:

34 * 100 + 56

If you need it as a string, then you can use the message builder.

##### Share on other sites

Would you then use the real to int function to put the result into a single register and just create a "dummy" register to hold the fractional part of the real to int function result?

On a related "newbie" type question, is there a means to set or reset multiple coils in a single instruction or is the only method to use the set and reset coil elements for each individual coil to set or reset?

Thanks!

Michael

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×