An extensive new survey finds British attitudes toward the European Union are improving ahead of a decisive referendum on whether to remain in the EU that must be held by the end of 2017.

The Pew Research Center report on attitudes in six European countries released Tuesday shows that 51 percent of Britons now have a favorable opinion about the EU, with positive feelings rising consistently since a low point was reached two years ago at the tail end of a prolonged economic slowdown. The rest had a somewhat or very unfavorable view of the EU, or refused to answer.

The findings are important because Prime Minister David Cameron, pressured by the right wing UK Independence Party and by many euroskeptics in his own party, is committed to a referendum on whether to withdraw from the 28-nation bloc.

Bruce Stokes, director of Pew's Global Economics Attitudes unit, said there has also been a marked growth in the number of Britons who believe economic integration with Europe has been positive for Britain.

"We found that 52 percent in Britain say the economy is doing good or very good," he said. "That's up from 15 percent in 2013, so that's a huge increase in two years. It's been a real change. That sets a positive mood for almost everything. It probably explains why we see support for staying in the EU going up."

An earlier Pew study in 2013 found Britons evenly split on the question of remaining in the EU. When that question was asked now, 55 percent said they want to stay while 36 percent wanted out.

Anand Menon, professor of European politics at King's College London, said the survey results seem accurate.

"I think the Brits have come to appreciate EU membership more now," he said, also citing economic improvement as a key factor, along with advice from business leaders about the many benefits EU membership has brought to Britain.

He said British citizens don't have a strong emotional attachment to the European Union, and many don't actually like it, but a large number believe they might be hurt economically if Britain were to withdraw.

The survey also saw a marked divide between younger and older voters, with a strong majority (69 percent) of people between the ages of 18 to 29 viewing the EU in a positive light. That figure has nearly doubled in the last two years, he said.

"It's basically driven by young peoples' desire to stay in the EU," he said. "There's clearly a generation gap. At the end of the day, this referendum will be about turnout. Who votes? If it's young people, the data would suggest the 'Yes' vote would pass, to stay, but if it's old people it could be a different story."

The Pew survey of more than 6,000 people in Britain, France, Germany, Italy, Poland and Spain found an across-the-board rebound in attitudes toward the EU since the crisis point of 2013, when the viability of the euro single currency seemed threatened. The margin of error for the British survey of 999 people was plus or minus 3.7 percentage points.

In Britain, the most vocal opposition to remaining in the EU has come from UKIP and its outspoken leader, Nigel Farage, who maintains that membership in the bloc has cost Britain control of its borders, allowing hundreds of thousands of immigrants to enter.

The party gained just over 13 percent of the popular vote in the May general election, and garnered one seat in Parliament, but the new survey shows that 66 percent of Britons believe the rise of UKIP to be a positive development because it is raising important issues ignored by the major parties.

"That suggests to me that there's a greater potential here than their actual vote," Stokes said. "If the economy went south, if things go sour, it does seem to me you could see the UKIP vote rise."