G
GaborSzakacs
Guest
crunchy.buscuits@gmail.com wrote:
"A minimum field width value may be included after the % character
(e.g. %10d). For decimal numbers, leading zeroes are replaced by
spaces, but for other radixes, the leading zeroes are printed. A
minimum field width of 0 means that the field will always be just
big enough to display the value."
This seems to make a lot of sense for numbers, but it wasn't
intuitively clear how this would affect strings, i.e. is a
null character really the same as leading zeroes in a numeric
value? Apparently so, and this is a great "trick" to know.
Thanks also to Stephen Willliams for posting the same answer.
--
Gabor
On Wednesday, July 10, 2013 3:42:01 AM UTC+1, Cary R. wrote:
I normally use "%0s" for this, but I don't know how portable it is.
Cool, that works. Tried it with ModelSim and Icarus Verilog and it works with both of those.
In my handy Doulos "Golden Reference Guide" for Verilog it says:
"A minimum field width value may be included after the % character
(e.g. %10d). For decimal numbers, leading zeroes are replaced by
spaces, but for other radixes, the leading zeroes are printed. A
minimum field width of 0 means that the field will always be just
big enough to display the value."
This seems to make a lot of sense for numbers, but it wasn't
intuitively clear how this would affect strings, i.e. is a
null character really the same as leading zeroes in a numeric
value? Apparently so, and this is a great "trick" to know.
Thanks also to Stephen Willliams for posting the same answer.
--
Gabor