Slumping personal computer maker Hewlett-Packard Co.’s latest quarterly results provided a glimmer of hope after months of gloomy news.

The fiscal first-quarter numbers announced Thursday topped the forecast of HP’s own management, as well as stock market analysts.

That’s an about-face from the previous two quarters, when HP announced losses totaling $15.3 billion as the company accounted for past acquisitions gone awry, to the shock of Wall Street.

Like other PC makers, HP has also been struggling to adapt to a shift toward smartphones and tablet computers, which are siphoning sales away from desktop and laptop machines made by HP and other companies.

Those problems are still plaguing HP, but the signs of progress in the latest quarter indicated that the company’s turnaround efforts are running ahead of schedule. CEO Meg Whitman has consistently said it may be several years before HP is on solid ground again.

“The patient showed some improvement,” Whitman told The AP Thursday. “I don’t want to get out over my skis.”

HP’s stock price surged $1.09, or 6.4 percent, to $18.19 in extended trading. The company earned $1.2 billion, or 63 cents per share, in the three months ending in January. That was a 16 percent decrease from nearly $1.5 billion, or 73 cents per share, at the same time a year earlier.

If not for certain accounting items, HP said it would have earned 82 cents per share. That was well above the average estimate of 71 cents per share among analysts surveyed by FactSet.

Revenue fell 6 percent to $28.4 billion, about $470 million above analyst projections. It’s the sixth consecutive quarter that HP’s revenue has dropped from the previous year.

Hewlett-Packard reported earnings two days after No. 3 PC maker Dell Inc. reported fiscal fourth-quarter sales and profit that topped analysts’ estimates, reflecting businesses’ demand for servers and software. Dell, which is trying to transform into a provider of a broad range of technology products, is planning to go private in a $24.4 billion deal.

Both companies are being dogged by a decline in PC demand. Shipments fell 4.9 percent in the fourth quarter, market researcher Gartner Inc. said. The rise of smartphones, tablets and software that runs via a browser are crimping sales.

“If you look at HP and Dell, they’ve both tried to be like IBM for the past five years,” Shaw Wu, an analyst at Sterne Agee & Leach told Bloomberg News. “You just don’t need as powerful a computer anymore, that’s the new market reality. It’s very different than a decade ago.”

There have been some bright spots for Hewlett-Packard in the computer market. Its share of fast-growing ultrathin notebooks was 14 percent in the fourth quarter, according to IDC, second only to Apple’s. CEO Meg Whitman has also said the company will eventually re-enter the smartphone market, after discontinuing phones using software from its Palm Inc. acquisition in 2011.

At a meeting with investors in October, Whitman and CFO Catherine Lesjak cut Hewlett-Packard’s earnings forecast for this year, blaming management upheaval and slow updates to key products. That sent the shares to a 10-year low at the time.

Hewlett-Packard said Nov. 20 it would write down most of the value of the Autonomy acquisition after discovering the unit had misrepresented its sales, sending shares plunging 12 percent that day.

(The AP and Bloomberg News contributed to this report)