Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c

What is scalbn() in C?

Khizar Hayat Saani

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

scalbn() is a built-in function defined in the <math.h> header in C.

The function prototype is:

double scalbn (double arg, int exp);

Functionality

scalbn() calculates and returns the product of arg and FLT_RADIX raised to the power exp.

FLT_RADIX

FLT_RADIX is the base for all floating point type variables and is defined in the <float.h> header. It is pre-set to a minimum value of 2.

The scalbn() Function

Code

#include <stdio.h>
#include <float.h>
#include <math.h>

int main ()
{
  double arg, result;
  int exp;

  arg = 4;
  exp = 3;
  
  result = scalbn (arg , exp);

  printf ("%f * %d^%d = %f\n", arg, FLT_RADIX, exp, result);
  return 0;
}

RELATED TAGS

c

CONTRIBUTOR

Khizar Hayat Saani
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring