program flt_zero;
initial begin
bit[31:0] a,b,sum;
shortreal fa, fb, fsum;
a = 'hbfe61122; b= 'h3fe61122;
fa = $bitstoshortreal(a);
fb = $bitstoshortreal(b);
fsum = fa + fa + fa + fb + fb +fb;
sum = $shortrealtobits(fsum);
$display("fsum is %f, sum is %h", fsum, sum);
end
endprogram
仿真结果:
fsum is -0.000000, sum is b4800000