Nintendo (OTC:NTDOY) has been a disaster over the past few years. The Wii, released in 2006, brought with it enormous profits and a soaring stock price. But this success didn't last, and Nintendo's successor to the Wii, the Wii U, has struggled. In each of the past three fiscal years, Nintendo has reported an operating loss, an unprecedented losing streak for the company.

But it seems Nintendo is starting to turn things around. The company reported an operating profit during the holiday quarter this year, and over the past nine months, it has posted an operating profit of about $270 million, using the current exchange rate. The era of losses appears to be over for Nintendo, at least for now. Here's what investors need to know.

Balancing the budget
Nintendo's sales are still declining, despite the swing in profitability. During the holiday quarter, Nintendo's sales fell by about 10% year over year. However, a drastically lower cost of goods sold led the company's gross margin to expand by about nine percentage points, from 29.9% during the holiday quarter of 2013 to 39% during the holiday quarter of 2014. Historically, Nintendo has enjoyed gross margins of around 40%.

This boost in gross margin was likely due to a decline in manufacturing costs for Nintendo's consoles, both the Wii U and the handheld 3DS. In general, Nintendo sells its hardware above cost, but a 3DS price cut back in 2011 had the company selling the hardware at a loss. Doing so was ultimately a wise move, as all of the variations of the 3DS have now sold in excess of 50 million units, creating a massive install base, but it certainly depressed profits during the past few years.

The Wii U was also sold at a loss when it first launched in 2012, atypical for Nintendo consoles. That situation, combined with the 3DS price cut, caused the company's gross margin to plunge as low as 22.1% in fiscal 2013. But the company has now reached a point at which the hardware seems to be generating a profit again thanks to lower manufacturing costs, meaning that gross margins around 40% are probably here to stay, at least until Nintendo launches its next console.

3DS sales declined during the first nine months of Nintendo's fiscal year, but the Wii U is slowly making a comeback. Nintendo sold 3.02 million Wii U consoles in the past nine months, up 25% compared with the same nine-month period last year, and software unit sales jumped nearly 30%. These are far lower sales figures compared with both Sony's PlayStation 4 and Microsoft's Xbox One, but the important thing is that Nintendo can be profitable at these sales levels.

Going forward, Nintendo has a lot going for it. It has a huge 3DS install base, and many games on that platform still sell very well. A Pokemon game released in November moved over 9 million units, according to Nintendo, and Super Smash Bros. sold 6 million units. The Wii U had some high-profile game launches in 2014, including Super Smash Bros. and Mario Kart 8, and 2015 will have its fair share as well. Even though Wii U sales have been anemic so far, any acceleration in Wii U sales at this point will only add to Nintendo's profits.

The value case for Nintendo
Shares of Nintendo are down about 65% over the past five years, and the market capitalization sits at about $11.3 billion. That figure may seem expensive for a company that managed an operating profit of just $270 million in the past nine months, but much of the value comes from Nintendo's massive pile of cash.

At the end of 2014, Nintendo had about $7.8 billion in cash and cash equivalents, using the current exchange rate. So the market is valuing all of Nintendo's future earnings at just $3.5 billion. Suddenly, Nintendo's valuation doesn't look so bad.

The big uncertainly with Nintendo is what happens next. Will there be another handheld console after the 3DS? Will smartphones render handheld consoles obsolete? Will Nintendo eventually launch a successor to the Wii U that proves more successful?

It's impossible to predict any of these things, but one thing is for certain: Nintendo is very good at making games that people want to play. How it monetizes that ability, along with its valuable intellectual property, may change in the future. Eventually, Nintendo may stop making hardware entirely, or perhaps it will stop making just handheld hardware, instead putting its games on phones and tablets.

There's a lot of uncertainty surrounding Nintendo right now. But I don't think there's a lot of risk. Nintendo has enough cash to survive just about anything, and the fact that the company can make money even with Wii U sales as low as they currently are bodes well for the future. The House of Mario looks like a value.