What makes a city unaffordable? One obvious answer is when rents and home prices have climbed to such heights that most ordinary people are completely priced out. But there's another way to look at it that may be even more important: If you move there, will you be able to afford to live?

For many major American cities, the answer is probably not. The personal finance site GOBankingRates examined 50 of the most populous cities in the U.S., comparing median salaries with average rent and other necessary expenses, which include groceries, health care, utilities, and transportation. Note that this figure does not include such extras as eating out, exercise, child care, or even clothing.

Nevertheless, in the cities listed here, even rent and other basic necessities totaled up to more than the median salary. That's before figuring in income tax, which is usually withheld from paychecks and really should not be considered an "extra."

It's fascinating that when you look at the prices for housing and living expenses in relation to what people actually earn, you get a whole different picture of which American cities should be considered unaffordable. Any list of the nation's most unaffordable cities by expense alone would feature many locations in California, especially San Francisco, San Jose, and other cities in Silicon Valley. San Francisco has the highest rents in the nation, averaging $4,500. But salaries in these places are apparently keeping up with expenses, comparatively speaking, because the only California city near the top of this list is Los Angeles. And some of the other cities, such as Pittsburgh, are not the glamour towns you might expect.

More than half your paycheck for rent?

The longstanding rule of thumb is that you should spend no more than 30 percent of your income on housing (rent or mortgage). None of the cities on this list fit under that rule if you compare average rents to median salaries. In some of them, average rents are well over half of average salaries. Meantime, some experts say that for many people even 30 percent is too high if they may also be paying for student debt and/or child care, two big monthly expenses that were less of a factor when this rule was created in the 1980s.

How do you survive in a city where your salary won't pay your rent and basic expenses? There are many answers to that question. Some people take on extra work to pad their bank accounts, or share housing with roommates, perhaps multiple roommates. Some people live in one place and commute to another. For example, a large percentage of the people who work in New York City live in New Jersey or Connecticut, or in less expensive towns in New York State.

But perhaps the best strategy -- for those who can -- is to work remotely for an employer in a high-rent area. For example, if you were working for a San Francisco company and earning the city's median salary of $77,582, but living in otherwise unaffordable Miami, you'd be paying an average of $23,998.29 a year for rent. You still wouldn't quite fit within the 30 percent rule, but you'd be pretty close.

You can find the full list of cities where you can't afford to live on a median salary here. These are the the ones with the biggest gaps:

1. Miami

Median income for one person: $25,233

Average rent for a one-bedroom apartment: $1,999.86 per month or $23,998.32 per year

Total annual cost of necessities: $45,808.56

Shortfall: -$20,575.56

Average rent as percentage of median salary: 95 percent

2. Philadelphia

Median income for one person: $28,351

Average rent for a one-bedroom apartment: $1,524.29 per month or $18,291.48 per year

Total annual cost of necessities: $40,951.58

Shortfall: -$12,600.58

Average rent as percentage of median salary: 65 percent

3. New York City

Median income for one person: $43,785

Average rent for a one-bedroom apartment: $2,376.93 per month or $28,523.16 per year

Total annual cost of necessities: $55,262.10

Shortfall: -$11,477.10

Average rent as percentage of median salary: 65 percent

4. New Orleans

Median income for one person: $26,927

Average rent for a one-bedroom apartment: $1,360.71 per month or $16,328.52 per year

Total annual cost of necessities: $36,097.55

Shortfall: -$9,170.55

Average rent as percentage of median salary: 61 percent

5. Los Angeles

Median income for one person: $41,568

Average rent for a one-bedroom apartment: $2,370.79 per month or $28,449.48 per year

Total annual cost of necessities: $50,431.91

Shortfall: -$8,863.91‬

Average rent as percentage of median salary: 68 percent

6. Baton Rouge, Louisiana

Median income for one person: $27,036

Average rent for a one-bedroom apartment: $983 per month or $11,796 per year

Total annual cost of necessities: $31,094.14

Shortfall: -$4,058.14‬

Average rent as percentage of median salary: 44 percent

7. Honolulu

Median income for one person: $42,568

Average rent for a one-bedroom apartment: $1,728.21 per month or $20,738.52 per year

Total annual cost of necessities: $45,772.13

Shortfall: -$3,204.13‬

Average rent as percentage of median salary: 49 percent

8. Baltimore

Median income for one person: $34,298

Average rent for a one-bedroom apartment: $1,383.71 per month or $16,604.52‬ per year

Total annual cost of necessities: $37,371.70

Shortfall: -$3,073.7‬0

Average rent as percentage of median salary: 48 percent

9. Tampa, Florida

Median income for one person: $34,559

Average rent for a one-bedroom apartment: $1,467.50 per month or $17,610‬‬ per year

Total annual cost of necessities: $37,351.20

Shortfall: -$2,792.2‬0

Average rent as percentage of median salary: 51 percent

10. Memphis, Tennessee

Median income for one person: $27,919

Average rent for a one-bedroom apartment: $791.43 per month or $9,497.16‬ per year

Total annual cost of necessities: $29,355.49

Shortfall: -$1,436.49‬

Average rent as percentage of median salary: 34 percent

11. Pittsburgh

Median income for one person: $31,496

Average rent for a one-bedroom apartment: $1,095 per month or $13,140‬ per year

Total annual cost of necessities: $31,955.73

Shortfall: -$459.73‬

Average rent as percentage of median salary: 42 percent

Correction: An earlier version of this page featured an image of Miami Beach, Florida, which the article didn't mention. The article's list also cited the incorrect measure for one-person income by city from the GOBankingRates study. It is the median income.