simonongsk

Using Word to perform calculation

5 posts in this topic

Hi:

        How to use data type Word to perform math function without converting to Int or Uint ?

 -----> Error    26    The '+' operator is not supported by WORD data type.    

thanks

 

 

Share this post


Link to post
Share on other sites

Can you post a picture of what you are trying to do?

Regards,
Garry

Share this post


Link to post
Share on other sites
16 hours ago, gclshortt said:

Can you post a picture of what you are trying to do?

Regards,
Garry

WordCounter:=WordCounter+UINT#1;

The error :Error    26    The '+' operator is not supported by WORD data type.  

Share this post


Link to post
Share on other sites
On 10/10/2020 at 0:48 PM, simonongsk said:

Hi:

        How to use data type Word to perform math function without converting to Int or Uint ?

 -----> Error    26    The '+' operator is not supported by WORD data type.    

thanks

 

 

You can't. A WORD datatype is defined as a bit string. So you can only use bitwise operators like AND OR XOR etc. You will need to change the datatype of the variable or convert the variable to an UINT,INT etc. 

Edited by chelton

Share this post


Link to post
Share on other sites

If you read the instructions, you can add data of different types, but the bit string types (BYTE, WORD, DWORD, LWORD) can NOT be added to the integer or real number types.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now