29.08.2014, 09:09
i have a float value: 0.33412359.
And i want to show this float 0.3 or 0.33! Help me
And i want to show this float 0.3 or 0.33! Help me
new Float: myFloat = 0.33412359;
printf("Original value: %f", myFloat);
printf("Only 1 number: %.1f", myFloat);
printf("Only 2 numbers: %.2f", myFloat);
//Prints:/*
Original value: 0.334123
Only 1 number: 0.3
Only 2 numbers: 0.33
*/