views:

170

answers:

1

I've got a calculation for example 57 / 30 so the solution will be 1,766666667.. How do i first of all get the 1,766666667 i only get 1 or 1.00 and then how do i round the solution (to be 2)?

thanks a lot!

A: 

57/30 performs integer division. To obtain a float (or double) result you should make 1 of the operands a floating point value:

result = 57.0/30;

To round result have a look at standard floor and ceil functions.

Vladimir