I wrote a program in C. Basically, the output is a point number. If I write "% .2lf", sometimes it ends, but I would like it to always be rounded. How can i do this?
Since you obviously want to get 2 digits left after the decimal point, you will need to convert the number before using ceil, and then translate it back:
ceil
val = ceil( val * 100.0 ) / 100.0 printf( "%.2lf\n", val );
Turn it on math.hif you don’t have it yet and do:
math.h
ceil(myDouble)
Use the function ceilfrom math.h.