import { Meta } from '@storybook/addon-docs/blocks'

<Meta title='@dxtmisha/en/functional-basic/Functions/getStepPercent - Calculate percentage step'/>

# `getStepPercent`

Calculates what percentage of the total range (between the minimum and maximum values) corresponds to a single unit (or one step = 1). This function is helpful when positioning segments of sliders or progress bars using percentages.

**Parameters:**
- `min: number | undefined` — The minimum value of the range. If `undefined` is passed, `0` is used.
- `max: number` — The maximum value of the range.

**Returns:**
`number` — The percentage (from 0 to 100) that one step occupies. If the maximum value is less than or equal to the minimum, it returns `0`.

```typescript
import { getStepPercent } from '@dxtmisha/functional-basic'

// Range from 0 to 200, so a step of 1 corresponds to 0.5%
console.log(getStepPercent(0, 200)) // 0.5

// Range from 50 to 150 (difference 100), a step is 1%
console.log(getStepPercent(50, 150)) // 1
```
