Fractional to decimal conversion
Convert Stock Quote from Fractinal to Decimal
Often secuirty prices are quoted in fractional form based on a denominator of 32. For example, if you see the quoted price is 100:05 it means 100 5/32. To find the equivalent decimal value, enter:
usddec = todecimal(100.05)
usddec = 100.1562
You can change the defualt denominator of 32 by using the
fracpart optional argument with a value of
usddec = todecimal(97.04, 16)
usddec = 97.2500
quote — Quoted security price
Quoted security price, specified as a scalar numeric or an
The convention of using
. (period) as a substitute for
: (colon) in the input is adopted from Excel® software.
fracpart — Fractional base (denominator) with which the security is normally quoted
(default) | scalar numeric
(Optional) Fractional base (denominator) with which the security is normally quoted, specified as a scalar numeric.
usddec — Fractional to decimal conversion
Fractional to decimal conversion, returned as a numeric decimal.
Introduced before R2006a