I have written a programm in C . Mostly, in the output is a point number. If I write "%.2lf" sometimes it round off but I would like that it allways round up. How can I do this?
Since you obviously want to get 2 digits left behind the decimal dot you would need to transform the number before you useceil and then transform it back:
val = ceil( val * 100.0 ) / 100.0
printf( "%.2lf\n", val );
Include math.h if you don't have it already, and do:
ceil(myDouble)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With