For *batting average*, every hit is ranked the same. Whether it's a single, double, triple, or home-run, it's a hit.
The batting average is found by dividing the number of hits by the number of at-bats. So if someone got one hit out of 4 at bats, he's batting .250. Sounds simple enough, right? Well, not quite.
First, we have to define what a "hit" is. As far as your batting average is concerned, a "hit" is when you strike the ball with the bat, and successfully reach first base due to your own success. What do I mean by that? Well for starters, if you only reach first base because the fielding team screwed up (ie, "committed an error"), you do not get a hit. You *should* have been out, and only reached base due to the other team's incompetance. Therefore, when it comes to figuring your batting average, that at-bat actually counts against you, just as if you'd gotten out instead of reaching base. Similarly, if you hit the ball and the fielding team throws the ball to second base to get your teammate out, you do not get a hit. It's called a Fielder's Choice - the only reason you reached base is because the other team *chose* to get your teammate out instead of you. They could have just as easily gotten you out instead, so you don't get a hit, it counts against you.
Secondly, we have to define what an "at-bat" is. An at-bat is any plate appearance that results in a hit, a fielder's choice, an error, or an out. If you get walked, or if the pitcher hits you with the ball, it's not an at-bat. You've taken first base because of it, but it's neither a hit nor an at-bat. You could conceivably get walked 4 times in one game, and you wouldn't have a single at-bat - you'd have gone 0 for 0 that day.
So, let's say these are Joe's plate appearances today:
1st Inning: walked
2nd Inning: grounded out to third
3rd Inning: double to left field
5th Inning: Reached 2nd base because the left fielder dropped the pop-up
7th Inning: Hit-by-pitch
8th: Inning: reached base when the fielder threw to second to get his teammate out
9th: Inning: Walk-off home run to win the game
What is Joe's batting average for today's game? He had 5 at bats (the walk in the 1st and the HBP in the 7th don't count) and got 2 hits, the double and the homerun. (The error in the 5th and the Fielder's Choice in the 9th don't count). So Joe batted 2-for-5 today, or .400, not a bad outing at all.
Note that there is a separate statistic, known as the "Slugging Percentage" or "Slugging Average". For this one, the number of bases you reach does matter. A triple is worth three times as much as a single. (That's not quite accurate, because if you get a single and later advance to third when your teammates are batting, you get the same as if you'd originally gotten a tripple). But for the batting average itself, a hit is a hit is a hit.