Hello, I am new to PBASIC and would like to know how to Concatenate a word variable. For example, the word could store 3000. I want it to change to 30. How would I do this?
Concatenate is a term usually used for strings of characters, not numbers. A word can hold any signed number from -32768 to 32767 or an unsigned (positive) number from 0 to 65535. The Stamps normally do arithmetic on unsigned word values, but you can work with signed 2's complement arithmetic if you're careful. A byte can hold an unsigned number from 0 to 255.
Sorry, you are right, I used the wrong term. I meant to remove. It want to only get the first two digits stored in a variable instead of four. Dividing by 100 would not help because in my case the variable's one's place is fluctuating its value from a sensor. It would be nice if I could make it a fixed number especially becuase I want to do further manipulation on it. Is there any way to do this?
Dividing by 100 would do it since division is integer arithmetic. Any remainder is discarded, so 3045 / 100 would be 30. If you want to round up, you'd do (3045 + 50) / 100.
Comments