- Function PriceDecimal(FractionalPrice, FractionBase)
PriceDecimal
The function PriceDecimal
converts a price expressed as a fractional
number to a price expressed as a decimal number depending on the input
parameter FractionBase.
PriceDecimal(
FractionalPrice, ! (input) numerical expression
FractionBase ! (input) numerical expression
)
Arguments
- FractionalPrice
The price expressed as a fractional number. FractionalPrice can be any real number.
- FractionBase
The base used as the denominator of the fraction. FractionBase must be a positive integer.
Return Value
The function
PriceDecimal
returns the FractionalPrice expressed as a decimal number.
Equation
The conversion between decimal and fractional prices is based on the system of equations
\[\begin{split}\begin{cases} \lfloor p_f \rfloor = \lfloor p_d \rfloor & \quad\mbox{(integer parts)}\\ p_f - \lfloor p_f \rfloor = \frac{b}{10^{\lceil \log{b}\rceil}}\left(p_d-\lfloor p_d \rfloor\right) & \quad\mbox{(fractional parts)} \end{cases}\end{split}\]where \(p_d\) is the decimal price, \(p_f\) the fractional price and \(b\) the base.
Note
For bases which are a power of 10, the decimal and fractional prices coincide. In all other cases, the fractional price is smaller than the decimal price.
The function
PriceDecimal
is similar to the Excel function DOLLARDE .
Example
_p_r1 := PriceDecimal( 1.02, 16 );
_p_r2 := PriceDecimal( 1.1 , 32 );
results in:
_p_r1 := 1.125000 ;
_p_r2 := 1.312500 ;