I am trying to write a number up to two decimal places using printf() as follows:
#include <cstdio> int main() { printf("When this number: %d is assigned to 2 dp, it will be: 2%f ", 94.9456, 94.9456); return 0; }
When I run the program, I get the following output:
# ./printf When this number: -1243822529 is assigned to 2 db, it will be: 2-0.000000
Why is this?
Thank.
c ++ c decimal printf
aali Jan 24 '11 at 16:23 2011-01-24 16:23
source share