Dear Dave&Team,
I would like to know the meaning of 1.3f used in Verilog to display a real number like 1.234 upto 3 digits .
real y ;
initial
begin
y = 1.234;
$display(“Value of y =%1.3f”,y);
end
Thanks
Susmita
Dear Dave&Team,
I would like to know the meaning of 1.3f used in Verilog to display a real number like 1.234 upto 3 digits .
real y ;
initial
begin
y = 1.234;
$display(“Value of y =%1.3f”,y);
end
Thanks
Susmita
In reply to sush:
Dear Dave&Team,
I would like to know the meaning of 1.3f used in Verilog to display a real number like 1.234 upto 3 digits .
real y ;
initial
begin
y = 1.234;
$display(“Value of y =%1.3f”,y);
end
Thanks
Susmita
1.3 f means it will display the value till 3 places i.e it displays 1.234
if 1.2 f , it will display till 2 places i.e 1.23
Hello Saurabh,
Thanks for a quick response .
Actually I wanted to know the significance of 1 in 1.3f and I understood significance of .3 i.e 3 digit places .
In reply to sush:
Look in section 21.2.1.2 Format specifications of the 1800-2012 LRM. It has all the answers for you.
Dear Saurabh,
I checked the same and came to know that if I use %2.3f as the format specifier ,2 represents minimum field width and 3 represents fractional digits .
Can you clarify the minimum field width concept as there is no example ?
Please give some example .
Thanks
Susmita
In reply to sush:
Just watch out the spaces it is taking while displaying.
%8.2f
This says you require a total field of 8 characters, within the 8 characters the last 2 will hold the decimal part.
%.2f
This requests the minimum field width and the last two characters are to hold the decimal part.
In reply to saurabh_3:
Thanks a lot …