Ethan Hein via Flickr Microsoft cofounder Paul Allen still calls Bill Gates his friend, but the two had a competitive and occasionally rocky relationship.

That's according to an excerpt from Allen's upcoming memoir, "Idea Man," published by Vanity Fair last night.

In it, Allen talks about how he met Gates at Lakeside Prep -- Seattle's top prep school -- and their early days at Microsoft together.

Allen paints Gates as an incredibly shrewd and competitive businessman, but acknowledges his brains and says that the two of them were basically on the same page when it came to general strategy and direction.

Here are some things we learned:

Gates was interested in business at a very early age -- when he was 13, he asked Allen "What do you thin it would be like to run a Fortune 500 company?" and suggested that the two of them would have their own company someday.

In high school, Gates was always showing off how smart he was, but he hit the wall at Harvard when he came up against other prodigies. He switched his major to applied math after getting a B in his first theoretical math course.

The night before they were due to show their first commercial project -- a programming language called BASIC for the Altair 8080 microcomputer -- Gates stayed up all night double-checking Allen's work to make sure it was free of errors. It was.

Allen came up with the name Micro-Soft.

Gates was a tough negotiator. When they formed the company, Gates suggested that they split revenues 60-40, with Gates getting the larger share because he'd done more work on BASIC. Allen accepted. A little later when they got their first big sale, Gates suggested a 64-36 split. Allen accepted again.

Gates expected long hours and perfect work, and occasionally insulted early Microsoft employees with statements like "I could code that in a weekend," but if they stood their ground and were correct, he would back down -- traits that he kept throughout his career at Microsoft, according to many anecdotes.

When they hired Steve Ballmer in 1980 to run the business side of Microsoft, Allen agreed to give him up to 5% of the young company's equity. Gates went behind his back and offered Ballmer 8.75%. Allen challenged Gates on it, and Gates offered to make up the difference out of his own share.

Allen tried to convinced Gates and Ballmer to switch from flat-fee licensing to per-unit royalties. He failed, but they later made the switch, and that business model is what made Microsoft the richest company in tech history.

In December 1982, when Allen was sick with cancer, he overheard Gates and Ballmer discussing his lack of contributions and how to dilute his equity by offering stock options to other employees and shareholders. Allen confronted them and quit a little bit later.

As he quit, Gates tried to buy his stock out for $5 per share. Allen asked for $10 and Gates refused. Allen kept his stock, which eventually made him one of the richest men in the world.

The entire excerpt is available here.

Now, don't miss: The Amazing Life Of Microsoft Cofounder Paul Allen.