Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c

What is expm1f in C?

Sheza Munir

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.

The expm1f function is a variation of the expm1 function.

The expm1 function calculates the e (Euler’s number, i.e., 2.7182818) raised to the given argument provided in the parameter, with the subtraction of 1.

If the argument has datatype float, expm1f is called. Otherwise, if the argument is of datatype int or double, expm1 is called.

Library

The expm1f function is accessible via the math.h library.

Parameters

The parameter provided to the function is a single argument of float datatype.

Return value

If the function encounters no errors, it returns the calculated value. In case of range errors, the function may not return the correct value. If the function encounters an underflowa number lower than the range of long double, it returns the correct result (after rounding). If the function encounters an overflowa number larger than the range of long double, it returns +HUGE_VAL +HUGE_VALF, or +HUGE_VALL.

Code

Below, we look at an implementation of the code:

#include <stdio.h>
#include <math.h>
int main()
{
float power = 3.4;
float returned = expm1f(power);
printf("(e^3.4) - 1 = %f", returned);
}

RELATED TAGS

c

CONTRIBUTOR

Sheza Munir
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