Get Integral Part of Decimal in C#

Updated on     Kisan Patel

To find the integer portion of a decimal or double number, you need to use System.Math.Truncate(Decimal or Double value) method as shown in below snippet:

decimal pi = (decimal)System.Math.PI;
//pi = 3.14159265358979

decimal dec = System.Math.Truncate(pi); 
//dec = 3

double trouble = 5.555;
double dbl = System.Math.Truncate(trouble);
//dbl = 5

C#

Leave a Reply