IMSL C Math Library
dollar_decimal
Converts a fractional price to a decimal price.
Synopsis
#include <imsl.h>
float imsl_f_dollar_decimal (float fractional_dollar, int fraction)
The type double function is imsl_d_dollar_decimal.
Required Arguments
float fractional_dollar (Input)
Whole number of dollars plus the numerator, as the fractional part.
int fraction (Input)
Denominator of the fractional dollar. fraction must be positive.
Return Value
The dollar price expressed as a decimal number. The dollar price is the whole number part of fractional-dollar plus its decimal part divided by fraction. If no result can be computed, NaN is returned.
Description
Function imsl_f_dollar_decimal converts a dollar price, expressed as a fraction, into a dollar price, expressed as a decimal number.
It is computed using the following:
where idollar is the integer part of fractional_dollar, and ifrac is the integer part of log(fraction).
Example
In this example, imsl_f_dollar_decimal converts $1 1/4 to $1.25.
 
#include <stdio.h>
#include <imsl.h>
 
int main()
{
float fractional_dollar = 1.1;
int fraction = 4;
float dollardec;
 
dollardec = imsl_f_dollar_decimal (fractional_dollar, fraction);
printf ("The fractional dollar $1 1/4 = $%.2f.\n", dollardec);
}
Output
 
The fractional dollar $1 1/4 =$1.25.