What is Math.ILogB() in C#?
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.
Syntax
public static int ILogB (double value);
Parameters
value: This is of theDoubletype and represents the input value for which we have to findILogB(). Its range is all double numbers.
Return value
Double: This returns a positiveDoublenumber representing the base 2 integer log of thevalue.MinValue: This returns an input of 0 invalue.MaxValue: This returns an input ofNaN,NegativeInfinity, andPositiveInfinityinvalue.
MinValueis the smallest possible Int32 value, equal to -2147483648.MaxValueis the largest possible Int32 value, equal to 2147483647.
Example
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);}}
Output
ILogB(10) = 3
ILogB(0) = -2147483648
ILogB(∞) = 2147483647