C# Math.BitIncrement() – Examples
In this tutorial, we will learn about the C# Math.BitIncrement() method, and learn how to use this method to find the next largest value for a given double, with the help of examples.
BitIncrement(Double)
Math.BitIncrement(x) returns the next largest value that compares greater than x
.
Syntax
The syntax of BitIncrement(Double) method is
</>
Copy
Math.BitIncrement(Double x)
where
Parameter | Description |
---|---|
x | The double value to increment. |
Return Value
The method returns a Double value.
Example 1 – BitIncrement(Double)
In this example, we will use Math.BitIncrement() method and find the next largest value for some double-point precision floating numbers.
C# Program
</>
Copy
using System;
class Example {
static void Main(string[] args) {
Double x, result;
x = 12.56;
result = Math.BitIncrement(x);
Console.WriteLine($"BitIncrement({x}) = {result}");
x = 10;
result = Math.BitIncrement(x);
Console.WriteLine($"BitIncrement({x}) = {result}");
}
}
Output
BitIncrement(12.56) = 12.560000000000002
BitIncrement(10) = 10.000000000000002
Conclusion
In this C# Tutorial, we have learnt the syntax of C# Math.BitIncrement() method, and also learnt how to use this method with the help of C# example programs.