When calculating market-cap of a company, do we take into account all shares or only the exchange traded shares?

The formula for the market cap is shares outstanding * share price. However, sometimes I see people only taking into account the shares that are publicly traded on the exchange when calculating market cap. So a company with 100,000 shares of which 20% is publicly traded at 100 dollars would have a market cap of 2,000,000 dollars; whereas a company with 100,000 shares of which 50% are publicly traded at 100 dollars would have a market cap of 5,000,000 dollars. Is this the wrong way of calculating the market cap?

It is very important to know what number for shares outstanding you are using. Let's say there is a hypothetical electricity company that creates 50 TWh / a and has 800 million shares outstanding, out of which 400 million are publicly traded. Let's also say you use 10000 kWh / a of electricity. The correct amount of shares to own to cover your electricity usage is 160: `10000e3/50e12*800e6 = 160`
Incorrect calculation would be `10000e3/50e12*400e6 = 80`