What happened

Shares of Micron Technology (MU -3.78%) were moving higher today after the memory-chip maker posted better-than-expected results in its fiscal second quarter.

As of 11:55 a.m. ET, the stock was up 5.8%.

So what

Micron, which specializes in DRAM and NAND flash-memory chips, is still struggling with headwinds in the semiconductor industry, but the company managed those challenges in the second quarter, cutting expenses and reducing supply, and it expressed optimism about a recovery.

Revenue in the quarter plunged 53% to $3.69 billion, due in part to falling prices, and that result essentially matched estimates at $3.7 billion.

In a reflection of how challenging industry dynamics have become, the company took an inventory write-down of $1.43 billion, which led it to report negative gross profit of $1.2 billion in the quarter. 

As a result, Micron finished the quarter with an adjusted net loss of $2.1 billion, or $1.91 per share, which was much worse than analyst estimates at $0.86 per share. 

But CEO Sanjay Mehrotra expressed optimism, saying, "Customer inventories are getting better, and we expect gradual improvements to the industry's supply-demand balance."

Now what

Micron's guidance was also ugly, showing it expects similar results in the third quarter, where it sees revenue of $3.7 billion, down 57% from the quarter a year ago, and negative gross margin of 23%, which reflects an expected $500 million in inventory write-downs. It also forecast an adjusted loss per share of $1.58, which was worse that the consensus for a loss of $0.90.

Management is taking steps to shore up the business, including supply reductions and reducing head count by 15%. The company also has more than $12 billion in cash on its balance sheet, and it should benefit when the cycle turns.

The stock's gains today and the mostly positive reaction from Wall Street seem to signal that the worst is behind it.