More than 3,000 prisoners in Washington have been mistakenly released early since 2002 because of an error by the state's Department of Corrections that resulted in wrongly calculated sentences for about 3 percent of the prison population.

At a news conference announcing the error Tuesday, Gov. Jay Inslee said he has ordered immediate steps to correct the longstanding computer glitch.

"Frankly, it is maddening," Inslee said.

Authorities say a July 2002 state Supreme Court ruling required the Corrections Department to apply good-behavior credits earned in county jail to state prison sentences. However, the programming fix ended up giving prisoners with sentencing enhancements too much so-called good time credit.

Sentencing enhancements include additional time given for certain crimes, like those using firearms or those committed near schools. Under state law, prisoners who get extra time for sentencing enhancements cannot have that time reduced for good behavior.

An analysis showed as many as 3,200 offenders were released early, and another 3,100 who are still incarcerated had inaccurate release dates.

Inslee's general counsel, Nicholas Brown, said most of the errors were 100 days or less. In some cases, inmates were released just a few days early, but at least one person who is still incarcerated had a release date that was off by about 600 days.

Based on a prior Supreme Court ruling, most of the affected offenders won't have to go back to prison. But officials have identified at least seven prisoners who were freed but haven't reached their corrected release date yet, and they will need to return to prison. Five of them have already been re-incarcerated.

The Department of Corrections was first alerted to the error in December 2012, when a victim's family learned of a prisoner's imminent release. The family did its own calculations and found he was being credited with too much time.

A timeline provided by the governor's office shows the agency consulted with attorneys regarding the error the same month and scheduled a fix for the program. However, the coding fix was repeatedly delayed, and the governor says he didn't learn of the issue until last week, when corrections' officials notified his staff.

"For reasons we still don't yet fully understand, that fix never happened," Brown said. Corrections Department Secretary Dan Pacholke, who took over as head of the agency in October and just learned of the error last week, also said he couldn't yet explain what happened.

"How that did not rise up in the agency to the highest levels is not clear to me," he said.

Brown said officials don't yet have a complete list of prisoners affected. The Corrections Department and governor's office have not released the names of those inmates who have been sent back to prison, or the name of the family who alerted the agency to the problem.

When asked if any of the prisoners who were released early committed additional crimes, Brown said, "We don't have the answer to that."

Inslee told corrections officials to stop releasing prisoners affected by the glitch until a hand calculation is done to ensure the offender is being released on the correct date. A broad fix to the software problem is expected to be in place by early January.

The governor said two retired federal prosecutors will conduct an independent investigation to figure out why it has taken so long to correct the problem.

"I have a lot of questions about how and why this happened, and I understand that members of the public will have those same questions," Inslee said.

Pacholke said he welcomed the external investigation.

"The agency should be held accountable for this breach," he said.

Republican state Sen. Mike Padden said the Law and Justice Committee he chairs will convene hearings on the early releases when the Legislature returns to the Capitol in early January.

"We will see what we can find out about this and whether any of these individuals have committed crimes and what crimes they committed when they should have been in prison," Padden said.