The formula for calculating a Bond's price uses the following formula:
Bond Price = C/t x ∑ C + M
(1 + r)t (1 + r)n
Bond Price = C/t + C/t + C/t +........+ Principal + C/t
(1 + R/t) (1 + R/t)2 (1 + R/t)3 (1 + R/t)n x t
C = Annual coupon payment amount which is paid over 'm' times a year
t = Coupon periodicity (semi-annual)
R = Yield-to-maturity expressed on the basis that the coupon is payable 'm' times a year
m = Redemption amount
n = Number of remaining coupons till maturity
Simply put, each cashflow is separately present valued and aggregated to arrive at the 'net present value', which is also the dirty price if calculated for a face value of 100/-, which is also the settlement amount in a bond trade.
In the following diagram, each moneybag represents the fixed semi-annual coupon payment and at maturity the last coupon payment and the Face Value of the Bond.

Let’s look at a Treasury Bond calculation using an example.
| Face Value of the Bond | = | LKR 1,000,000 |
| Maturity Period | = | 2 Years |
| Yield to Maturity | = | 12%p.a. |
| Coupon Rate | = | 10%p.a. paid semi-annually |
| Cash Flow 1 | Cash Flow 2 | Cash Flow 3 | Cash Flow 4 | |
| C/t (1 + R/t) |
C/t (1 + R/t)2 |
C/t (1 + R/t)3 |
C/t (1 + R/t)4 |
|
| 100,000/2 (1 + 0.12/2) |
100,000/2 (1 + 0.12/2)2 |
100,000/2 (1 + 0.12/2)3 |
1,000,000+(100,000/2) (1 + 0.12/2)4 |
|
| 50,000 1.06 |
50,000 1.1236 |
50,000 1.191016 |
1,050,000 1.262477 |
|
| 47,169.81 | 44,499.82 | 41,980.96 | 831,698.35 | |
| Bond Value | = Cash Flow 1 + Cash Flow 2 + Cash Flow 3 + Cash Flow 4 = 47,169.81 + 44,499.82 + 41,980.96 + 831,698.35 = LKR 965,348.94 |
|||