ch2-Integers
2019-10-24
Integer
Integers are numbers without a fractional part or in other words, they are whole numbers. SystemVerilog has three new signed data types to hold integer values each with a different size. The smallest is shortint
which can range from -32768 to 32767, and the largest is longint
. The sign can be explicitly defined using the keywords signed
and unsigned
. Also they can be converted into one another by casting.
Signed
By default**, integer variables are signed in nature** and hence can hold both positive and negative values.
1 |
|
Unsigned
We’ll change variables declared in the example above to be of unsigned
type and see how the results look like.
1 |
|
byte
A byte
is an even shorter version of an integer with a size of 8 bits. By default byte
is a signed variable and has the same properties as an integer described in the previous section
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!