Stocks gained Thursday as oil prices fell, with investors choosing to ignore the morning's big spike in U.S. consumer inflation and instead purchase shares battered in the recent retreat. Light sweet crude oil for September delivery fell 99 cents to $115.01 a barrel on the New York Mercantile Exchange on beliefs that a slowing U.S. economy will lower oil prices. In economic news, U.S. consumer inflation rose to a 5.6 percent annual rate in July, hitting a 17-year high. “Core” consumer inflation, which excludes volatile energy and food costs, rose 2.5 percent compared to a year ago and 0.3 percent for the month. U.S. foreclosure filings jumped 8 percent in July and 55 percent from a year ago, a private group reported. A separate report showed a 7.6 percent decline in existing-home prices from a year ago. The Dow Jones industrial average rose 82.97, or 0.7 percent, to 11,615.93. Twenty-six of the index's 30 components rose, led by General Motors, Home Depot and financial firms J.P. Morgan Chase, Citigroup, Bank of America, and AIG. Wal-Mart reported higher quarterly profits and sales but warned that current-quarter profits could miss analysts' forecasts. Its shares rose slightly. The broader Standard & Poor's 500 index rose 7.10, or 0.55 percent, to 1,292.93. The technology-heavy Nasdaq composite index rose 25.05, or 1 percent, to 2,453.67. The New York Stock Exchange composite index rose 10.58 to 8,385.97. The American Stock Exchange composite index fell 11.79 to 2,056.15. And the Russell 2000 index rose 6.69 to 754.38.