Resulting sign and bit length using Conditional Operator

Hi Sir,

Taking inspiration from thread, I was trying to achieve int’( ) cast using 32’( ) cast and vice-versa ( edaplayground )

One difference between them is that unlike int’( ) cast, 32’( ) cast doesn’t change the state of the expression

Assuming that expression is always 2-state, I was able to achieve int’( ) using 32’( ) in both cases ( expression could be signed / unsigned )

However when expression is signed ( -4’sd4), I am observing unexpected results when achieving 32’( ) cast using int’( ) cast

(Q) Any suggestions ? Using if-else condition would work but wouldn’t be valid within with() clause of sum()

Could Implication operator → help ?