Two technology names that you have undoubtedly heard of are software behemoth Microsoft (MSFT -2.45%) and computer and printer specialist HP Inc. (HPQ 0.11%). Of the two, Microsoft is clearly the more successful company, commanding a market capitalization of $861 billion, dwarfing HP's $30 billion.

That said, they are operating in entirely different businesses and, naturally, past performance is no guarantee of future success. So, which of these stocks is the better bet for your portfolio now? Let's compare.

A person's hands typing on a laptop keyboard.

Image source: Getty Images.

Microsoft is a more diverse business

HP Inc. makes its money by selling personal computers and related devices, printers, and supplies for those printers. According to market researchers with IDC, HP was the top PC maker by unit share, capturing 23.2% of the market in 2018 -- though it did slip into second place by a very narrow margin during the fourth quarter. The company also captured 40.5% of the hardcopy peripherals market in 2018, according to IDC, boosting its unit share by 1.9% year over year.

While HP has leading positions in these technologies, it's important to understand that they are highly competitive markets. That's why its personal systems business had an operating margin of just 4.2% last quarter. The printing business is structurally more profitable, with the segment enjoying 16.2% operating margin. 

Microsoft, on the other hand, primarily sells software and services, which tend to carry structurally higher gross margins than hardware. However, it's also worth noting that it also sells hardware products, such as its Surface computers and related accessories, as well as its Xbox gaming consoles (although those largely serve as a means to sell higher-margin services and to collect significant royalties on video game sales). 

For some perspective, though, Microsoft's operating margin last quarter was about 31.6%.

Microsoft in short, is a much more diverse business. HP's success is largely tied to the PC and printing markets, while Microsoft is exposed to cloud computing, productivity software, gaming, and PC sales -- which it profits from via high-margin licenses of the Windows operating system. 

I'd also argue that Microsoft is, in aggregate, better poised for growth over the long-term than HP is, because it's exposed to more -- and, in general, better -- markets. 

Check out the latest earnings call transcript for Microsoft and HP.

Valuations

Microsoft is able to turn more of its revenue into operating profit than HP is, and has better growth prospects too. 

With that being said, HP trades at about 9 times analyst's earnings per share (EPS) projections for 2019, and 8.6 times their 2020 EPS projections. HP isn't a growth superstar, but it's also not priced like one. 

Microsoft, on the other hand, trades at 25.3 times analysts' fiscal 2019 EPS projections and 22.5 times their fiscal 2020 EPS expectations. The software giant's revenue is expected to rise 12.4% in its fiscal 2019, and 10.4% in the subsequent year. 

So, Microsoft is relatively pricey, but in return you get a company with a number of fast-growing businesses in its arsenal, and, in general, significant competitive moats. HP is much cheaper, but it's a much slower-growth business, with revenue expected to rise just 0.8% in 2019 followed by a 1% bump in its fiscal 2020. 

Dividends

One area in which HP simply crushes Microsoft is dividends. Both companies are committed to annual payout increases, but Microsoft's dividend yield is just 1.64% while HP's is a much more robust 3.28%. (HP's yield has recently been helped along by a significant drop in its share price.)

So, if you're an income-oriented investor, HP's shares may be more attractive to you than Microsoft's. 

Investor takeaway

Microsoft is an incredible company with a diverse business portfolio. HP is also a leader in its fields, although the ones it plays in aren't as fast-growing -- nor, arguably, as exciting -- as Microsoft's key arenas. 

With that being said, HP offers a fatter dividend than Microsoft does, and my view is that sentiment around Microsoft continues to be very favorable, while the market seems to be quite down on HP after its most recent earnings results. This could mean that although Microsoft is arguably the better business, HP could potentially provide better stock returns than Microsoft over the medium term if, say, Microsoft hits a speed bump and HP manages to deliver a nice recovery from here. 

However, if I were to choose one of these two stocks to buy and hold for the next couple of decades, I'd have to give the nod to Microsoft.