(Adds economist's comment, details on sterling, yen, dollar contracts, byline)

By Gertrude Chavez-Dreyfuss

NEW YORK, July 8 (Reuters) - Currency speculators raised their net long position on the U.S. dollar and Japanese yen as they sought safety two weeks after the United Kingdom's shock vote to exit the European Union.

The value of the dollar's net long position rose to $4.18 billion in the week ended July 5, from $3.01 billion the previous week, according to Reuters calculations and data from the Commodity Futures Trading Commission released on Friday.

It was the eighth straight week that the dollar posted a net long position.

Speculators also raised sterling net shorts to 49,031 contracts in the latest week, while they boosted net longs on the yen to 63,568 contracts, the largest such position since early May.

Short-term investors have been short the British pound since November, and long the yen since January.

Since the Brexit vote, the pound has fallen more than 14 percent.

"Post-Brexit-vote pain is beginning, and it will get worse," said Bill Witherell, chief global economist at Cumberland Advisors. "Investors' attitudes about Britain's prospects are signaled by the tumbling currency."

It was no surprise that speculators have bought the safe-haven yen and dollar given sterling's woes.

The yen has proven to be one of the strongest performers in the market, with gains of nearly 20 percent so far this year against the dollar. The currency is on pace to post its best yearly gain since the 2008 global financial crisis.

The dollar has had a mixed performance. For the year, the dollar index .DXY has been down 2.4 percent, but since May, it has gained 5.2 percent on worries about Brexit.

The Reuters calculation for the aggregate U.S. dollar position is derived from net positions of International Monetary Market speculators in the yen, euro, sterling, Swiss franc and Canadian and Australian dollars.

Japanese Yen (Contracts of 12,500,000 yen)

July 5, 2016 Prior week

week Long 87,037 85,493 Short 23,469 25,743 Net 63,568 59,750

EURO (Contracts of 125,000 euros)

July 5, 2016 Prior week

week Long 112,011 109,580 Short 187,338 171,514 Net -75,327 -61,934

POUND STERLING (Contracts of 62,500 pounds sterling)

July 5, 2016 Prior week

week Long 45,746 43,274 Short 94,777 85,985 Net -49,031 -42,711

SWISS FRANC (Contracts of 125,000 Swiss francs)

July 5, 2016 Prior week

week Long 22,474 22,905 Short 13,796 12,038 Net 8,678 10,867

CANADIAN DOLLAR (Contracts of 100,000 Canadian dollars)

July 5, 2016 Prior week

week Long 41,031 38,675 Short 29,514 30,726 Net 11,517 7,949

AUSTRALIAN DOLLAR (Contracts of 100,000 Aussie dollars)

July 5, 2016 Prior week

week Long 33,794 32,556 Short 28,891 34,508 Net 4,903 -1,952

MEXICAN PESO (Contracts of 500,000 pesos)

July 5, 2016 Prior week

week Long 24,238 13,390 Short 69,095 78,717 Net -44,857 -65,327

NEW ZEALAND DOLLAR (Contracts of 100,000 New Zealand dollars)

July 5, 2016 Prior week

week Long 30,606 29,798 Short 32,009 32,624 Net -1,403 -2,826

(Reporting by Gertrude Chavez-Dreyfuss; Editing by Leslie Adler and Richard Chang) ((gertrude.chavez@thomsonreuters.com; 646-223-6322; Reuters Messaging: rm://gertrude.chavez.reuters.com@reuters.net))