8 Jun 2005 08:27
format in m4
Andrew Collier <andrew.collier <at> alfvenlab.kth.se>
2005-06-08 06:27:46 GMT
2005-06-08 06:27:46 GMT
hello,
i have come across something unexpected using 'format' with m4. i am wanting to just trim off the decimal
portion of a number. however, when the 'trimmed' number ends with zeros these get removed as well. for example:
m4_format(`%.0f', 293408.883333)
m4_format(`%.0f', 293409.883333)
m4_format(`%.0f', 293499.883333)
which produces:
293409
29341
2935
so, the first line works fine. the second and third lines do not produce what i expected at all. i thought that
maybe i had misunderstood the implementation of 'format', so i coded the above in c:
printf("%.0f\n", 293408.883333);
printf("%.0f\n", 293409.883333);
printf("%.0f\n", 293499.883333);
and in this case i get precisely what i wanted:
293409
293410
293500
i am using GNU m4 1.4.1.
(Continue reading)
RSS Feed