C# Math.BitDecrement() – Examples

In this tutorial, we will learn about the C# Math.BitDecrement() method, and learn how to use this method to get the next smallest value for a given double, with the help of examples.


Math.BitDecrement(x) returns the next smallest value that compares less than x.



The syntax of BitDecrement(Double) method is

Math.BitDecrement(Double x)


xThe double value to decrement.

Return Value

The method returns a Double value.

Example 1 – BitDecrement(x)

In this example, we will use Math.BitDecrement() method and find the next smallest value for a given double value x.

C# Program

using System;
class Example {
    static void Main(string[] args) {
        Double x, result;

        x = 12.56;
        result = Math.BitDecrement(x);
        Console.WriteLine($"BitDecrement({x}) = {result}");

        x = 10;
        result = Math.BitDecrement(x);
        Console.WriteLine($"BitDecrement({x}) = {result}");


BitDecrement(12.56) = 12.559999999999999
BitDecrement(10) = 9.999999999999998


In this C# Tutorial, we have learnt the syntax of C# Math.BitDecrement() method, and also learnt how to use this method with the help of C# example programs.