Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c

# What is fmal in C? Adnan Abbas

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.

fmal is a mathematical function in C that multiplies two values together. It then adds a third value and rounds the result, ensuring correct precision while intermediary rounding.

## Syntax

long double fmal(
long double  x,
long double  y,
long double z
);


## Parameters

• x is the first value to multiply.
• y is the second value to multiply.
• z is the value to add.

## Return value

The function returns the value of (x*y) + z as calculated to infinite precision and rounded once to adjust according to the result data type.

The following table lists some values on which the function returns other values:

Input Returned value
x = INFINITY, y = 0 or x = 0, y = INFINITY NaN
x or y = exact ± INFINITY, z = INFINITY with the opposite sign NaN
x or y = NaN NaN
Overflow range error ±HUGE_VAL, ±HUGE_VALF, or ±HUGE_VALL
Underflow range error correct value, after rounding.

## Example

The following code shows how to use the fmal function in C – we store the result of the computation in fmal_result and print it as a floating point value:

#include<stdio.h>
#include <math.h>
int main() {
double fmal_result = fmal(0.01,10,0.001); //calling the function fmal
printf("fmal(0.01,10,0.001) = %f\n", fmal_result);//

}

RELATED TAGS

c

CONTRIBUTOR Adnan Abbas 