Skip to main content

Practice ยท 3 of 4

Truncate, then round

CHALLENGE
Difficulty: beginner+25 XP

Implement two functions: static int Truncate(double d) returning the integer part, and static int Round(double d) returning d rounded to nearest (midpoint away from zero). Use casts and Math.Round deliberately.

Back to lesson: Practice: Types under pressure