C# Tutorial C# Advanced C# References

C# Math - ScaleB() Method



The C# ScaleB() method returns a x 2b.

Syntax

public static double ScaleB (double a, int b);

Parameters

a Specify value to be scaled by power of 2.
b Specify power of 2 used to scale a.

Return Value

Returns a x 2b.

Example:

In the example below, ScaleB() method returns a x 2b.

using System;

class MyProgram {
  static void Main(string[] args) {
    Console.WriteLine("Math.ScaleB(2.55, 4) = "
                      + Math.ScaleB(2.55, 4));
    Console.WriteLine("Math.ScaleB(10, 3) = "
                      + Math.ScaleB(10, 3));
    Console.WriteLine("Math.ScaleB(Double.NaN, 3) = "
                      + Math.ScaleB(Double.NaN, 3));
    Console.WriteLine("Math.ScaleB(Double.PositiveInfinity, 3) = "
                      + Math.ScaleB(Double.PositiveInfinity, 3));
  }
}

The output of the above code will be:

Math.ScaleB(2.55, 4) = 40.8
Math.ScaleB(10, 3) = 80
Math.ScaleB(Double.NaN, 3) = NaN
Math.ScaleB(Double.PositiveInfinity, 3) = Infinity

❮ C# Math Methods

5