Hillary Rodham Clinton is a liberal Democrat on domestic matters, and Bernie Sanders is a socialist. They voted the same way 93 percent of the time in the two years they shared in the Senate.

In fact, from January 2007 to January 2009, Mrs. Clinton, representing New York, voted with Mr. Sanders about as often as she did with the like-minded Democrats Ron Wyden of Oregon and Barbara Mikulski of Maryland.

In many of the cases in which she differed with Mr. Sanders, who represents Vermont and is also running for the Democratic presidential nomination, Mrs. Clinton went with the crowd. She voted with an overwhelming majority of her colleagues, including Republicans. Her positions on the votes that differed from Mr. Sanders represented policy differences, but they may have also reflected political calculations by Mrs. Clinton, who was preparing for a presidential run in 2008.

The 31 times that Mrs. Clinton and Mr. Sanders disagreed happened to be on some the biggest issues of the day, including measures on continuing the wars in Iraq and Afghanistan, an immigration reform bill and bank bailouts during the depths of the Great Recession. Mr. Sanders, who formally kicked off his campaign Tuesday evening in Burlington, Vt., was opposed to all these actions.