Is it worth driving farther for cheaper gas prices?

This browser does not support the video element.

CHARLOTTE — If you’ve ever wondered if driving a few miles out of the way to buy cheaper gas really saves you money, Action 9 investigator Jason Stoogenke has the answer.

He says it depends.

Stoogenke says you have to do some math, and he has a formula you can use.

According to multiple websites, here’s how to figure it out:

First, write down these five numbers:

A: How many gallons you need.

B: The miles per gallon your car gets.

C: How much the closer (more expensive) gas cost.

D: How much the farther (less expensive) gas cost.

E: The distance between the two.

Here’s an example:

A: 10 (gallons)

B: 25 (mpg)

C: $4.60

D: $4.40

E: 4 (miles)

Here’s the equation:

(A x C) – ((A x D) + ((E/B) x C))

Plug in the numbers:

(10 x 4.60) - ((10 x 4.40) + ((4/25) x 4.60))

Remember to do the math in paratheses first:

(46) - (44 + (.16 x 4.6))

46 - (44 + .74)

46 - 44.74

1.26.

In the example, you’d save money ($1.26 total).

Click here to use a calculator tool that will do the math for you. It also factors in your time and wear and tear on your car.

(WATCH BELOW: Controlling your costs: How to better your gas mileage)

This browser does not support the video element.