How to round of Decimal Number ?
-
If the number is 24.58. How to round of it as 25? If the number is 24.34 How to round of as 24.
-
If the number is 24.58. How to round of it as 25? If the number is 24.34 How to round of as 24.
-
If the number is 24.58. How to round of it as 25? If the number is 24.34 How to round of as 24.
Hello,
double round(double Num, double Seed) { double fac = Num / Seed; fac = (fac < 0) ? (ceil(fac - 0.5)) : (floor(fac + 0.5)); // fac = (fac < 0) ? static_cast(fac-0.5) : static_cast(fac+0.5); return fac * Seed; }
round(3.7856, 0.001); = 3.786 Hope this helps. Bekir -
If the number is 24.58. How to round of it as 25? If the number is 24.34 How to round of as 24.
Try this method int nRoundFigure; nRoundFigure = (int)( 24.58 + 0.5 ); // Answer will be 25 nRoundFigure = (int)( 24.34 + 0.5 ); // Answer will be 24 Hope this will work:)
Known is a drop, unknown is an ocean