how do i convert value and round off int values?
Example:
int x = 121;
int y = Math.Ceiling(x/8);
Get Error:
Cannot implicitly convert type double
to int
. An explicit conversion exists (are you missing a cast?)
CEILING works like the MROUND function, but CEILING always rounds up. The Excel EVEN function rounds numbers up to the next even integer. The EVEN function always rounds numbers away from zero, so positive numbers become larger and negative numbers become smaller (i.e. more negative).
Description. Returns number rounded up, away from zero, to the nearest multiple of significance. For example, if you want to avoid using pennies in your prices and your product is priced at $4.42, use the formula =CEILING(4.42,0.05) to round prices up to the nearest nickel.
Math. ceil(<some value>) returns a double, not an integer.
Returns a number rounded up to a supplied number that is away from zero to the nearest multiple of a given number.
You can try using this:-
int x = 121;
int y = (int)Math.Ceiling((double)x/8);
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