Technology kingpins Microsoft (NASDAQ:MSFT) and Apple (NASDAQ:AAPL) were once harsh rivals in the personal computer market, but the paths of the two have diverged and now encompass far more than just computers.

Microsoft is best known for its Office productivity software and Windows operating system, and Apple for a host of personal computing devices led by its flagship iPhone -- which recently helped Apple become the first U.S. company with a $1 trillion valuation.

With both stocks near all-time highs, let's see which one is worth buying or adding to today.

Consecutively growing stacks of coins with dollar signs and an increasing graph trend line.

Image source: Getty Images.

Financial fortitude

Every company will eventually face tough times, and our tech giants are no different. Let's review a number of metrics to see how they stack up when it comes to their ability to endure financial hardship.

Metric

Apple

Microsoft

Revenue (TTM)

$255.3 billion

$110.4 billion

EBITDA (TTM)

$84.1 billion

$49.5 billion

Net income (TTM)

$56.12 billion

$16.6 billion

Cash from operations (TTM)

$73 billion

$43.9 billion

Free cash flow (TTM)

$58.6 billion

$32.3 billion

Cash and marketable securities

$243.7 billion

$133.8 billion

Long-term debt

$114.60 billion

$76.24 billion

Data source: YCharts and company financial reports. TTM = trailing 12 months.

It's important to note that Apple has more than $173 billion in long-term marketable securities on its balance sheet that I included in its cash and marketable securities calculation -- in order to show the truly rock-solid nature of the company's financial position. 

These figures reveal that both companies have strong balance sheets and more than adequate reserves in the event of a downturn. But massive revenue and free cash flow generation give the edge here.

Advantage: Apple.

Competitive advantage

Both Apple and Microsoft boast significant competitive advantages, though they come by them in different ways.

Apple is one of the most valuable brands among consumers, and the loyalty of iPhone users is well known. Apple has been able to leverage the strength of that brand and its ecosystem to entice users to try other products, like the iPad or the Apple Watch. The company's growing list of ancillary services -- like iCloud and Apple Music -- gives its customers additional incentives to remain Apple loyalists and to plunk down more of their hard-earned money. Services is now one of Apple's fastest growing segments, up 31% year over year in its most recent quarter.

Microsoft's competitive advantage lies in how deeply embedded it is in the enterprise market. Windows commands a desktop market share of nearly 83%, more than three decades after it was first released, and the company's Office productivity software is still the industry standard. The addition of the Azure cloud and LinkedIn business social network have further entrenched the company in the business world.

With no true apples-to-apples comparison available, I'm calling this one a tie.

Advantage: None.

AAPL Dividend Chart

Data by YCharts.

Dividends and buybacks

Any discussion of these two tech titans wouldn't be complete without a nod to the funds they are returning to shareholders via dividends and buybacks. Over the past half-decade, Microsoft has repurchased nearly 8% of its shares, but Apple has bought back nearly 23% of its stock over the same period.

Both companies have been diligent about increasing their payouts. Microsoft's dividend has increased 93% over the past decade, while Apple's has jumped 110%.

Microsoft has the edge when it comes to yield, at 1.55%, and is currently only paying out 77% of its profits to support the dividend -- but that requires some explanation. The company took a one-time charge of $13.8 billion in its fiscal second quarter related to U.S. tax reform late last year, which skewed the results. Adjusting for this one-time event results in a much more reasonable payout ratio of 42% -- leaving plenty of room for future increases.

Apple has a current yield of 1.35%, slightly lower than Microsoft, but is paying out just 23% of its earnings to fund the dividend, giving it much greater ability to fund increases going forward.

Even with Microsoft's slightly higher payout, Apple's recent dividend growth has been greater, and it has a much greater ability to fund future increases.

Advantage: Apple.

Valuation

Any better-buy scenario would be remiss if it didn't include a review of valuation. Applying several different widely used valuation metrics will give us a sense of which company might represent a better value. Here's how they compare using price-to-earnings (P/E) and price-to-free-cash-flow (P/FCF).

Metric

Apple

Microsoft

Trailing P/E

20

52

Forward P/E

19

26

P/FCF

19

26

Data source: YCharts.

At first glance, it appears Apple has this locked down, but once again, Microsoft's trailing P/E ratio is thrown off by the aforementioned tax charge. Adjusting for that one-time charge, Microsoft's valuation drops to a much more competitive trailing multiple of 28, but that's still not low enough to keep up with Apple.

Advantage: Apple.

The better buy is...

Apple's sterling financial position, generous capital return program, and less expensive valuation make the stock a better buy right now.

Teresa Kersten is an employee of LinkedIn and is a member of The Motley Fool's board of directors. LinkedIn is owned by Microsoft. Danny Vena 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.