C# Convert ToInt16(Single)
Description
Convert ToInt16(Single)
converts the value of the specified
single-precision floating-point number to an equivalent 16-bit signed
integer.
Syntax
Convert.ToInt16(Single)
has the following syntax.
public static short ToInt16(
float value
)
Parameters
Convert.ToInt16(Single)
has the following parameters.
value
- The single-precision floating-point number to convert.
Returns
Convert.ToInt16(Single)
method returns value, rounded to the nearest 16-bit signed integer. If value is halfway
between two whole numbers, the even number is returned; that is, 4.5 is converted
to 4, and 5.5 is converted to 6.
Example
/*from w w w . j a v a 2s . c o m*/
using System;
public class MainClass{
public static void Main(String[] argv){
Console.WriteLine(Convert.ToInt16((Single)123.123F));
}
}
The code above generates the following result.