I wrote this on a break at work, but couldn't post it until I got home. The above information is good, but if you'd like more depth, here you go.

As a caveat to this post: I know nothing about the mechanics of buying and selling bonds. Some information contained herein was obtained from a simple Google search. However, I know quite a bit about the theoretical pricing of bonds (and I passed a very hard test last April wherein that was a central idea). Please read this post with that information in mind.

Bonds are structured similar to annuities. In the case of Treasury Bonds, the structure is most similar to a "balloon loan". That is, the bond pays out a pre-defined amount of interest every six months, called a coupon payment, then pays the par amount or face value of the bond at maturity (30 years in the case of a 30-year bond). Some bonds can be paid off early; this is referred to as a call. The terms under which a bond can be called are specified in the terms of the bond itself. Treasury Bonds issued after 1985 do not have call provisions and cannot be called. When a Treasury Bond is issued, it will be issued at a specified interest rate for a specified amount of time to maturity with a specific par value. You mentioned a 30-year bond issued at 3.8% interest. We'll simplify things and use $1,000 as the par value of the bond. What this means is that the bond will pay out .038*($1,000) = $38 per year, $38/2 = $19 every six months. $19 is the coupon payment. There will be 60 coupon payments of $19. When the bond hits maturity at year 30, the payout will be the face value of the bond, $1,000, plus the last coupon payment, $19, for a total of $1,019.

When you buy a bond, you do not necessarily pay the par value of the bond. I believe that, in the case of Treasury Bonds bought directly from the federal government, the U.S. Treasury publishes an asking price for bonds the week before bonds are sold. Then investors submit offer prices to the Treasury. The Treasury then sells a predetermined number of bonds based on the offers. I think most individual investors buy bonds on the secondary market. That is, they buy bonds from brokerages, banks, etc. that bought their bonds from the federal government. Either way, the price you pay for a bond is based on the current interest rate, not necessarily the rate at which the bond was issued. Bonds that are bought at par value will achieve a rate of return equal to the annualized effective interest rate of their coupon rate ((1 + .038/2)^2 - 1 = 3.836% in the example above).

To determine the rate of return that you will achieve from a bond purchased at a price other than the par value and held to maturity, you will need a tool that can perform financial math. Excel (or an Excel equivalent) will suffice. Let’s consider the above bond with a purchase price of $990. In order to determine the six month effective interest rate for this bond, we will use the Excel function RATE(nper, PMT, PV, FV), where nper is the number of bond payments, PMT is the amount of each coupon payment written as a negative number, PV is the price of the bond written as a positive number, and FV is the par value of the bond written as a negative number. For our example, type “=RATE(60, -19, 990, -1000)” and press enter. Excel should compute the six month effective rate of return to be 1.928%. To convert this to an annual effective rate of return, use the formula “=(1 + RATE(60, -19, 990, -1000))^2 - 1”. You will get an annual effective rate of return of 3.894%, slightly higher than the annualized effective interest rate of the coupon rate as a result of the $10 discount off of the par value of the bond. Try finding the effective annual rate of return of the bond purchased at $1010. You should get 3.779%.

Up until this point we have only considered bonds held to maturity, but what if we want to sell or price the bond before maturity? The value of your bond at any time is dependent on the interest rates at the time that you are selling. However, instead of depending on the 30-year Treasury Bond interest rate, the new rate will depend on shorter term bonds. The reason for this is simple; the buyer of the bond is assuming less risk by buying a less-than-30-year bond than a buyer of a 30-year bond would be assuming. To price the bond, we will use another Excel function, PV(rate, nper, PMT, FV), where rate is the new interest rate divided by two (since you receive two coupons every year), nper is the number of coupon payments left until maturity, PMT is the negative value of the coupon payments, and FV is the negative par value. Consider our above bond ten years before maturity. Now let’s assume that the interest rate on 10-year Treasury Notes is 5%. To find the selling price of our bond we will use the function “=PV(.05/2, 20, -19, -1000)”. The bond will sell at $906.47. The reason that the bond sells below par value is that the buyer of the bond could, instead, buy a newly issued 10-year Treasury Note and receive higher coupon payments of $25 every six months. Therefore, they deserve a discount on the purchase price in order to even things out. If, instead, the interest rate on a 10-year Treasury Note were 2%, we could sell the bond for PV(.02/2, 20, -19, -1000) = $1,162.41.

Now, how do we compute the rate of return on a bond sold before maturity? We will return to the RATE(nper, PMT, PV, FV), where nper is the number of coupon payments we received, PMT is the negative coupon payment, PV is the positive price we paid for the bond, and FV is the negative price we received for the bond. We will work an example where the above bond was bought for $990, received 40 coupon payments over 20 years, and was then sold with 20 coupon payments remaining when the interest rate on 10-year Treasury Notes was 3.75%. The negative price for which we sell the bond will be -PV(.0375/2, 20, -19, -1000) making the six month effective rate of return RATE(40, -19, 990, -PV(.0375/2, 20, -19, -1000)) = 1.943%. The annual effective rate of return is then (1 + RATE(40, -19, 990, -PV(.0375/2, 20, -19, -1000)))^2 - 1 = 3.924%.

**tldr;** a Treasury Bond is like an annuity that only pays interest until its maturity date. If interest rates go up after you purchase your bond, the value of the bond will decrease. If interest rates go down after you purchase your bond, the value of the bond will increase. However, the payments for the lifetime of the bond will not change.