Home » excel » Bond Price fraction convert to decimal 32nd excel formula

# Bond Price fraction convert to decimal 32nd excel formula

Posted by: admin May 14, 2020 Leave a comment

Questions:

i am pretty sure a lot of people in capital market experience this :
use excel formular to convert fraction to decial in 32nd

i know most case we just divide last 2 digits decimal place by 32 for example:

100-160= 100+16/32=100.5
100-200=100+20/32=100.625

but if 3 decimal places : 99-226=99+(22+6/8)/32=99.7109375

how do we convert it to formula in excel , please help!!!!

How to&Answers:

Assuming a data setup like this where your Bond Prices are in column A and your formula for Decimal Conversion is in column B: The formula in cell B2 and copied down is:

``````=LEFT(A2,FIND("-",A2)-1)+(MID(A2&"00",FIND("-",A2)+1,2)+MID(SUBSTITUTE(A2,"+",4)&"000",FIND("-",A2)+3,1)/8)/32
``````

### Answer：

Alternative Using FilterXML() function

Adding a further column B with the following xml conversion

``````="<t><a>" &SUBSTITUTE(SUBSTITUTE(A2,"+","4"),"-","</a><b>")&"</b></t>"
``````

you can calculate results in a next column via `FilterXML()` available in Excel 2013+:

``````=FILTERXML(B2,"//a")+(LEFT(TEXT(FILTERXML(B2,"//b"),"000"),2)+RIGHT(TEXT(FILTERXML(B2,"//b"),"000"),1)/8)/32
``````

tl;tr – one column solution (just for fanatics)

Of course you could also force the xml base into one formula:

``````=FILTERXML("<t><a>" &SUBSTITUTE(SUBSTITUTE(A2,"+","4"),"-","</a><b>")&"</b></t>","//a") + (LEFT(TEXT(FILTERXML("<t><a>" &SUBSTITUTE(SUBSTITUTE(A2,"+","4"),"-","</a><b>")&"</b></t>","//b"),"000"),2)+RIGHT(TEXT(FILTERXML("<t><a>" &SUBSTITUTE(SUBSTITUTE(A2,"+","4"),"-","</a><b>")&"</b></t>","//b"),"000"),1)/8)/32
``````