Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How vb converts 4-byte floating-point numbers into integers
How vb converts 4-byte floating-point numbers into integers
There are two conversion methods:

1. float = 1. 1f by forced type conversion. //Define a floating-point variable aintb =(int)a .// Here, the (int) method is used to force the float, and the result is 1.

2. In the truncated integer part, by converting it into a string, float =1.1f. //define a floating-point variable Stringstr=String.valueOf(a). //The floating-point variable A is converted into the string Strindidx = Strindidx = str.lastindexof (".").//Find the position of the decimal point StringstrNum=str.substring(0, idx). //Intercept the string from the beginning of the string to the decimal point, that is, the integer part intnum=Integer.valueOf(strNum). //Convert the integer part into a number through the Integer.valueof method.