A simple method is to cast directly to the int type, that is, the integer part. Subtract this int type, which is the decimal part.
The code is as follows:
Floating point number n =12.223;
int x =(int)n;
float y = n-(float)x;
X is the integer part of the data, and y is the decimal part of the data.
:
Floating-point data type, which is used to store single-precision floating-point numbers or double-precision floating-point numbers. What is the use of floating-point numbers? IEEE (Institute of Electrical and Electronics Engineers) format. The single-precision value of floating-point type has 4 bytes, including a sign bit, an 8-bit excess-127 binary exponent and a 23-bit mantissa. The mantissa represents a number between 1.0 and 2.0. Since the high-order bit of mantissa is always 1, it is not stored in digital form. This representation provides a range between -3.4E+38 and 3.4E+38 for the float type.
(Source: Baidu Encyclopedia: FLOAT)