The surprise profit sent shares soaring to a two-and-a-half-year high.

"In November at our investor meeting, we talked about the two problems we had to solve: declining comparable store sales and declining operating margins," Mr Joly said, in a statement accompanying the earnings.

"Since that time... we have made measurable progress... including near flat comparable store sales, substantive cost take outs, and better-than-expected earnings in the past three consecutive quarters."

Best Buy has struggled with declining sales at its major stores and with an increasingly competitive online retail environment.

Although sales at its US stores shrunk by 0.4% in the second quarter, the numbers were nonetheless better than many analysts had been expecting and included one-time factors like changes to store layouts.

Best Buy is developing store layouts more common to US department stores which will feature "stores within stores" such as Samsung Experience shops and Windows stores.

There are no quick fixes to correct the errors of the pastMike Ullmann, JC Penney

'No quick fixes'

However, earnings in the second quarter for two other giant US retailers were not as bright.

Struggling department store chain JC Penney reported a loss of $586m and said sales had declined by 12% from the same period last year.

"There are no quick fixes to correct the errors of the past," newly installed interim boss Mike Ullman said.

Mr Ullman was brought back to the company he once led this year after the disastrous tenure of Ron Johnson.

Mr Johnson's efforts to do away with discounts and overhaul inventory led to a $1bn loss in his first year as JC Penney's boss.

Hedge fund titan William Ackman resigned from the board of JC Penney last week, after a tumultuous few months in which he had sought to have Mr Ullman removed and yet another new boss installed.

Mr Ackman, who owns 18% of the company, had chosen Mr Johnson to lead the company's turnaround in 2011.

JC Penney's board had fought back against Mr Ackman's wishes, calling his actions "disruptive and counterproductive".

Back-to-school blues

Book store chain Barnes & Noble also reported weak results, as consumers continued to seek out cheaper used books and e-books online.

The book retailer reported a loss of $86m.

In a separate filing, chairman of Barnes & Noble's board Leonard Riggio said he was putting on hold his stated efforts to buy the retailer's consumer book stores.

"While I reserve the right to pursue an offer in the future, I believe it is in the company's best interests to focus on the business at hand," said Mr Riggio in a filing with US regulators.

The company has yet to name a new boss after William Lynch left in July.

Overall, the retail environment in the US is not expected to improve, and other retailers have warned about a weaker-than-expected back-to-school sales shopping period.

The world's largest retailer Wal-Mart reported weak sales last week and said it expected demand to remain low for the rest of the year. Macy's and Kohl's also reported softening demand and lowered their guidance for the rest of the year.

The period in late summer from mid-July to mid-September is typically the second largest sales period in the US, after the holiday season.

Although US retail sales in July were modestly positive, businesses did not stock up on as much inventory as had been expected.

Despite this, many observers expect that central bankers at the US Federal Reserve will announce at the end of their two-day September meeting plans to begin to wind down a period of extraordinary monetary easing meant to prop up the fledgling US recovery.