Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How does C# get the values before and after the decimal point?
How does C# get the values before and after the decimal point?
float num = 123.3 1;

int I =(int)num; //This is 123, this is abandoned.

int I = int . prase(num); //Same as above, this seems to be rounded (I'm not sure about this, you can try)

int f = num/ 1 * 100; //is 3 1

There is another way.

string str=num。 ToString();

string[] c=str.split(' . ');

int . prase(c[0]); //stands for 123, an integer.

int . prase(c[ 1]); //means 3 1, an integer.