They are three of the biggest and oldest names in technology. When you combine the value of Apple (NASDAQ:AAPL), Microsoft (NASDAQ:MSFT), and IBM (NYSE:IBM), you have a mind-boggling $1.5 trillion, bigger than the GDP of all but 10 countries globally.

These three have been millionaire-maker stocks over the years, but which of them is the best stock to own for the future?

A person working on a tablet with imaginary apps hovering above it

Image source: Getty Images

That's not a question we can answer with 100% certainty. But by viewing all three through a few crucial lenses, we can get a much better feel for what we're getting when we buy shares. Run them through the gauntlet, and the winner -- and loser -- emerges.

Sustainable competitive advantage

There's nothing more important to the long-term success of a stock that the sustainable competitive advantage -- often referred to as a "moat" -- of the underlying company. At its most basic level, a moat is what separates you from the competition. It's that special something that keeps customers coming back for more, year after year -- all while holding the competition at bay for decades.

Apple has two main moats. The first is the power of its brand. According to Forbes, the Apple brand alone is worth $170 billion, tops in the world. That allows the company to charge significantly more for its products than the competition does. People are simply willing to pay up for Apple. Just as important, because Apple's products enter you into the iEcosystem -- think about how your laptop, iPhone, and TV can all talk to each other and access the iCloud -- it has mildly high switching costs. Simply put, customers are more likely to stick with Apple once they are in.

Microsoft is no slouch when it comes to moats, either. It has the world's third most valuable brand, coming in with a value of $87 billion. But the company's real strength comes from high switching costs -- much higher, I would argue, than Apple's. The company's Office Suite of Word, Excel, and PowerPoint have been standard bearers for over two decades -- which is equivalent to eons in the tech world. Clearly, users are hooked on these applications, and they provide powerful motivation to continue using the products.

IBM, on the other hand, struggles quite a bit when it comes to its moat. The company is focused on business analytics, dubbed "Strategic Imperatives." And while those analytics also have high-switching costs -- no one wants to switch away from platforms they're familiar with -- they aren't as time tested as Microsoft's.

In the end, I think Microsoft wins because it's less focused on hardware than Apple is and has a much longer history of proven high-switching costs.

Winner: Microsoft.
Runner-up: Apple.
Loser: IBM.

Financial fortitude

While all three of these stocks were once blazing growth names, they have settled down considerably. These days, those who buy their shares are often more interested in the dividend. So it might make sense to desire a company that pays most of its cash out to shareholders.

But there's something to be said for keeping a large cash stash on hand. That's because every company will at some point experience financial difficulties. Those that meet these periods with lots of cash can actually get stronger -- by buying back shares on the cheap, acquiring rivals, or outspending the competition to gain market share.

Those that have lots of debt have none of these options and are often very fragile when it comes to such downturns. Keeping in mind that Apple is valued at 40% larger than Microsoft and almost six times the size of IBM, here's how they stack up.

Company

Cash

Debt

Net Income

Free Cash Flow

Apple

$262 billion

$90 billion

$47 billion

$52 billion

Microsoft

$139 billion

$76 billion

$21 billion

$31 billion

IBM

$25 billion

$38 billion

$12 billion

$15 billion

Data sources: Yahoo! Finance, E*Trade. Net income and free cash flow presented on trailing-12-month basis. Cash includes short- and long-term investments.

All three of these companies are stable, with tons of free cash flow going into their pockets. However, from a leverage standpoint, it's hard to find a company in better standing to benefit from a downturn than Apple. The company has over a quarter-trillion in cash on its balance sheet.

Beyond that, Microsoft easily beats out IBM, as the latter has more long-term debt on hand than cash.

Winner: Apple.
Runner-up: Microsoft.
Loser: IBM.

Valuation

Finally, we have the murky science of trying to figure out how expensive these three stocks are. While there's no single, tried-and-true metric to use, there are a number of data points we can reference to build a more holistic picture. Here are five of my favorite.

Company

P/E

P/FCF

PEG Ratio

Dividend Yield

FCF Payout

Apple

18

16

1.5

1.6%

24%

Microsoft

23

18

2.1

2.1%

38%

IBM

12

9

4.5

4.2%

35%

Data sources: Yahoo! Finance, E*Trade. P/E calculated using non-GAAP earnings.

Here we have a very mixed picture. IBM appears to be both the cheapest, and the highest yielder. While the latter is certainly true, the former isn't as clear, as it looks extremely expensive once growth potential (the PEG ratio) is taken into consideration.

Between the other two players, Apple and Microsoft are close, but Apple has the edge, coming out as cheaper on all the standard metrics, and having even more room for growth in the dividend, by way of its payout ratio from free cash flow.

Winner: Apple.
Runner-up: Microsoft.
Loser: IBM.

My best stock to buy is...

So there you have it: According to my criteria, Apple is the best stock to buy out of the bunch, though Microsoft comes in a very close second, and IBM is in a distant third place.

Teresa Kersten is an employee of LinkedIn and is a member of The Motley Fool's board of directors. LinkedIn is owned by Microsoft. Brian Stoffel owns shares of Apple. The Motley Fool owns shares of and recommends Apple. The Motley Fool has the following options: long January 2020 $150 calls on Apple and short January 2020 $155 calls on Apple. The Motley Fool has a disclosure policy.