C# Math - BitIncrement() Method
The C# BitIncrement() method returns the next largest value that compares greater than the argument. In special cases it returns the following:
- If the argument is NaN, the method returns NaN.
- If the argument is positive infinity, the method returns positive infinity.
Syntax
public static double BitIncrement (double arg);
Parameters
arg |
Specify the value to increment. |
Return Value
Returns the next largest value that compares greater than the argument.
Example:
In the example below, BitIncrement() method returns the next largest value that compares greater than the argument.
using System; class MyProgram { static void Main(string[] args) { Console.WriteLine("Math.BitIncrement(2) = " + Math.BitIncrement(2)); Console.WriteLine("Math.BitIncrement(10.1) = " + Math.BitIncrement(10.1)); Console.WriteLine("Math.BitIncrement(32.23) = " + Math.BitIncrement(32.23)); Console.WriteLine("Math.BitIncrement(0) = " + Math.BitIncrement(0)); Console.WriteLine("Math.BitIncrement(-10.1) = " + Math.BitIncrement(-10.1)); Console.WriteLine("Math.BitIncrement(Double.NaN) = " + Math.BitIncrement(Double.NaN)); Console.WriteLine("Math.BitIncrement(Double.NegativeInfinity) = " + Math.BitIncrement(Double.NegativeInfinity)); Console.WriteLine("Math.BitIncrement(Double.PositiveInfinity) = " + Math.BitIncrement(Double.PositiveInfinity)); } }
The output of the above code will be:
Math.BitIncrement(2) = 2.0000000000000004 Math.BitIncrement(10.1) = 10.100000000000001 Math.BitIncrement(32.23) = 32.230000000000004 Math.BitIncrement(0) = 5E-324 Math.BitIncrement(-10.1) = -10.099999999999998 Math.BitIncrement(Double.NaN) = NaN Math.BitIncrement(Double.NegativeInfinity) = -1.7976931348623157E+308 Math.BitIncrement(Double.PositiveInfinity) = Infinity
❮ C# Math Methods