Batting average is calculated by taking hits and dividing by at bats.
At bats does not include walks, hit by pitch, or sacrifice flies or bunts. At bats also does not include when the batter is substitued during the at bat or if a runner is thrown out to end the inning before completing the at bat.