FUNCTION
dollar_fraction
Finance functions
Interface
#include <codecogs/finance/banking/dollar_fraction.h>
using namespace Finance::Banking;
Converts a decimal price to a fractional price, using the following equation:
(1)
where <em>iprice</em> is the integer part of <em>decimalPrice</em> and <em>ifrac</em> is the integer part of <em>log(fraction)</em>
Example 1
#include <stdio.h>
#include <codecogs/finance/banking/dollar_fraction.h>
int main()
{
double d = Finance::Banking::dollar_fraction(1.38, 8);
printf("The decimal price $1.38 as fractional (8 denominator) = %.1f\n", d);
return 0;
}Output:
The decimal price $1.38 as fractional (8 denominator) = 1.3Parameters
decPrice
is the decimal price.
frac
is the denominator required for the fraction output.
Interactive Calculator
decPrice
frac
Result
Computing…
Set a range above first to export a graph.
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.