MathF.Truncate() Method in C# with Examples
In C#, MathF.Truncate(Single) is a MathF class method which is used to compute an integral part of a specified single number or single-precision floating-point number.
Syntax:
public static float Truncate (float x);
Parameter:
x: It is the specified number which is to be truncated and type of this parameter is System.Single.
Return Type: This method only return the integral part of x and discard the fractional part. The type of this method is System.Single.
Example:
// C# Program to illustrate the // MathF.Truncate(Single) Method using System; class Geeks { // Main Method public static void Main() { // varibles of float type float x1 = 7845.56478452f; float x2 = 12548.3242f; // using method and displaying result Console.WriteLine(MathF.Truncate(x1)); Console.WriteLine(MathF.Truncate(x2)); } } |
7845 12548
Recommended Posts:
- MathF.Sin() Method in C# with Examples
- MathF.Min() Method in C# with Examples
- MathF.Log() Method in C# with Examples
- MathF.Exp() Method in C# with Examples
- MathF.Max() Method in C# with Examples
- MathF.Cos() Method in C# with Examples
- MathF.Abs() Method in C# with Examples
- MathF.Tan() Method in C# with Examples
- MathF.Pow() Method in C# with Examples
- Double.CompareTo Method in C# with Examples
- Type.FindInterfaces() Method in C# with Examples
- Int64.CompareTo Method in C# with Examples
- Type.FindMembers() Method in C# with Examples
- SByte.ToString Method in C# with Examples | Set - 2
- String.Split() Method in C# with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



