_fyl2x -- Calculate y * log2(x)

Format

#include <builtin.h>
double _fyl2x(double x, double y);

Language Level: Extension
_fyl2x computes the base-2 logarithm of x and multiplies it by y (y * log2(x)). The variable x cannot be negative. This instruction is designed with built-in multiplication to optimize the calculation of logarithms with arbitrary positive base: log b (x) = (log2(b)**-1) * log2(x)

Because it is a built-in function and has no backing code in the library:

Return Value
_fyl2x returns the result of the formula y * log2(x).

Example
This example calculates (y * log2(x)), after prompting the user for values of x and y.

#include <builtin.h>
#include <stdio.h>
int main(void)
{
   double x, y;
   printf("Enter a value for x:\n");
   scanf("%lf", &x);
   printf("Enter a value for y:\n");
   scanf("%lf", &y);
   printf("%lf * log2(%lf) is %lf.\n", y, x, _fyl2x(x, y));
   return 0;
   /*******************************************************
      Assuming you enter 4.0 for x and 3.0 for y.
      The output should be:
      3.000000 * log2(4.000000) is 6.000000.
   *******************************************************/
}



_fyl2xp1 -- Calculate y * log2(x + 1)
_f2xm1 -- Calculate (2**x) - 1
<builtin.h>