Cast, Int. Floating point values can be cast to ints. This has predictable results. We find out the result of a conversion to an integer from a value that cannot fit in an integer. We show conversions from double, long and ulong to int.

Example. First, when you cast doubles to ints, the values after the decimal place will be dropped in the resulting value. This is similar to Math.Floor in this aspect. This is demonstrated with four double values.

Discussion. This is important because if you ever cast fractional values to integers, you will know they are always rounded down to the nearest integer. This means even the value 1.99 is changed to 1. The (int) cast never rounds the value up.

Also: When we cast longs, ulongs or doubles that cannot fit in the memory space of an int, we receive predictable but unusable results.

Tip: If you want to be alerted if such an error occurs, use the checked context. Also note the unchecked context to disable this.