M
Mike
Guest
Hi,
In the verilog spec IEEE P1364-2005/D3 section
4.1.3 "Using integer numbers in expressions",
there are the following examples about signed
arithmetic (see below).
Can someone explain the second example?
Assuming that their results are printed in base 10,
I cannot figure out how the result is 1431655761.
Thanks in advance,
Mike
--------------------------------------------------
integer IntA;
IntA = -12 / 3; // The result is -4.
IntA = -'d 12 / 3; // The result is 1431655761.
IntA = -'sd 12 / 3; // The result is -4.
IntA = -4'sd 12 / 3; // -4'sd12 is the negative of the 4-bit
// quantity 1100, which is -4. -(-4) = 4.
// The result is 1.
In the verilog spec IEEE P1364-2005/D3 section
4.1.3 "Using integer numbers in expressions",
there are the following examples about signed
arithmetic (see below).
Can someone explain the second example?
Assuming that their results are printed in base 10,
I cannot figure out how the result is 1431655761.
Thanks in advance,
Mike
--------------------------------------------------
integer IntA;
IntA = -12 / 3; // The result is -4.
IntA = -'d 12 / 3; // The result is 1431655761.
IntA = -'sd 12 / 3; // The result is -4.
IntA = -4'sd 12 / 3; // -4'sd12 is the negative of the 4-bit
// quantity 1100, which is -4. -(-4) = 4.
// The result is 1.