C# has a built-in Math
class that provides useful mathematical functions and operations. This class has the ILogB()
function, which is used to compute the base 2 integer logarithm of a specified number.
public static int ILogB (double value);
value
: This is of the Double
type and represents the input value for which we have to find ILogB()
. Its range is all double numbers.Double
: This returns a positive Double
number representing the base 2 integer log of the value
.MinValue
: This returns an input of 0 in value
.MaxValue
: This returns an input of NaN
, NegativeInfinity
, and PositiveInfinity
in value
.
MinValue
is the smallest possible Int32 value, equal to -2147483648.MaxValue
is the largest possible Int32 value, equal to 2147483647.
using System;class Educative{static void Main(){double result = Math.ILogB(10);System.Console.WriteLine("ILogB(10) = "+ result);double result1 = Math.ILogB(0);System.Console.WriteLine("ILogB(0) = "+ result1);double result2 = Math.ILogB(Double.PositiveInfinity);System.Console.WriteLine("ILogB(∞) = "+ result2);}}
ILogB(10) = 3
ILogB(0) = -2147483648
ILogB(∞) = 2147483647