Converts a fractional price to a decimal price.
#include <imsl.h>
float imsl_f_dollar_decimal (float fractional_dollar, int fraction)
The type double function is imsl_d_dollar_decimal.
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.
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.
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).
In this example, imsl_f_dollar_decimal converts $ 1 1/4 to $1.25.
#include <stdio.h>
#include "imsl.h"
void 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);
}
The fractional dollar $1 1/4 = $1.25.
|
Visual Numerics, Inc. PHONE: 713.784.3131 FAX:713.781.9260 |