SyntaxFix
Write A Post
Hire A Developer
Questions
A neat trick for fast rounding is to add .5 before you cast your decimal to an int.
decimal d = 10.1m; d += .5m; int i = (int)d;
Still leaves i=10, but
i=10
decimal d = 10.5m; d += .5m; int i = (int)d;
Would round up so that i=11.
i=11