Washington (CNN) -- Sometimes the most complicated of cases at the Supreme Court brings out the best arguments. It certainly brought out the giggles in a little-watched appeal Tuesday over federal prison terms.

The justices managed to crack themselves up -- along with the public audience -- at least a dozen times in the hourlong oral debate. Justice Clarence Thomas rarely speaks at the high court's normally sober sessions, but he especially enjoyed the gentle insults and self-deprecating jibes his colleagues showered on each other. His booming laugh could be clearly heard at times.

At issue was how the federal Bureau of Prisons should calculate "good-time credit" -- reduced sentences for inmates staying out of trouble in custody. Prisoners can earn up to 54 days of credit for each year of the sentence.

The ambiguity comes with language in the federal law on how to add up the credits. Prisoners and even law enforcement officials find the formula complicated. The high court agreed Tuesday -- repeatedly.

Justice Antonin Scalia suggested the good-time credits kick in at day 311 -- 54 days before year's end -- and not day 365.

Jeffrey Wall, arguing for the government, replied, "Justice Scalia, I think that sets up an odd system,"

Scalia pointed his finger at Wall's adversary, a federal public defender sitting in the next table, who was nodding his head vigorously at Scalia's comments. "See, he agrees with me!" said the justice.

Justice John Paul Stevens later expressed concern at the government's position. "If there are 195,000 people spending significantly more time in jail than they should, that's kind of troublesome"

Wall explained that is how prison officials have been doing it since 1987, and Congress never bothered to amend the good-time formula.

"Probably they [lawmakers] didn't understand it because it's an awfully hard statute to understand."

Wall jumped in. "Justice Stevens, with all due respect, Justice [Stephen] Breyer got it in the first five minutes."

Under the current interpretation, the government does "the measurement [of good-time credit] at the end of the 365 days," she told Stephen Sady, lawyer for the inmates. "Let's say he misbehaves on the 340th day, and they say for that reason, we're only going to give you 10 days of credit. So now your year starts at 350?"

"355. Yes," Sady corrected her, politely of course..

"No 350, because they are only giving 10 days of good-time credit." She paused for a second. "Because at the end of-- wait-- 355..."

"355," answered Sady, politely of course, but smiling.

"That was pretty bad," said Sotomayor, hands raised, shaking her head and chuckling at her mistake. The courtroom erupted in laughter.

Despite the fun, the question is a serious one for the nearly 197,000 federal prisoners and their families, according to the most recent weekly population report issued by the Justice Department. Ninety-five percent of the inmates are affected by the good-time provision. Lawyers for the inmates say the savings to taxpayers under their reading of the law would amount to $953 million a year now being spent to incarcerate current prisoners.

The case is Barber v. Thomas (09-5201). A written ruling -- minus any jokes -- is expected by June.