Search | Synergex.com | Contact Us | Resource Center Login | Home|
News

What type of field can store a numeric value between 0 and 255, inclusive, in a single byte?

a. a
b. byte
c. i
d. all of the above

Explanation:
Let's assume our variable is named v.  If v is declared as an a1, then the statement:

v = 255

will result in a value of '5', due to left-truncation of a decimal to alpha store.

However, you can store a value from 0 through 255 in an a1 by using either the supplied subroutine ASCII or the supplied function %CHAR:

xcall ascii(255, v)
v = %char(255)

Then you can extract it using %DECML(v).

If v is a byte or an i1, these types are signed (except for byte on .NET). The value 255 sets all 8 bits including the most significant one, yielding a two's complement representation of -1.

However, you can interpret them as unsigned using %UNSIGNED(v).

Thus, (d) is the correct answer—if you know how to do it.


More information about News and Events

Contact Synergex to learn more about  News and Events