# Batting Average

**Formula:**`Batting Average = `

*H* / *AB*

## Introduction to Batting Average

Batting average in baseball is calculated by dividing the total number of hits by the total number of at-bats. In this formula, ** H** represents the number of hits and

**represents the number of at-bats. The result represents the player's success in making hits during official at-bats. Batting average is typically represented to three decimal places, e.g., .314.**

*AB*## Parameter usage:

`hits`

= number of hits`atBats`

= number of at-bats

## Example valid values:

`hits`

= 113`atBats`

= 357

## Output:

`Batting Average`

= batting average of the player

## Data validation

The number of at-bats should be greater than 0.

## Summary

This calculator computes the batting average of a baseball player based on the number of hits and at-bats.

Tags: Baseball, Sports, Statistics