Batting average is the oldest and one of the most important statistics used in baseball.
Steps:
1. Add up your hits.
2. Add up your at bats. At bats include every time you hit safely or hit into an out, including a strike out. Getting on base by an error or fielder's choice is considered an out. A Sacrifice, walk or hit by pitch is not counted as a hit or an out.
3. Divide your hits by your at bats.
4. Round off the number to the third decimal place. For example, .33051 is .331.
Tips:
A walk or a hit by pitch will not hurt your batting average but will increase your on-base percentage.
If you hit safely but are out trying to get an extra base on the same play, it is still considered a hit.
Warnings:
Batting average is not as important for a leadoff hitter as on-base percentage is.
Source: http://stathistory.com/06/formulas.asp