Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 19 Jun 2011 10:42:56 -0500 From: Pete Becker Organization: Roundhouse Consulting, Ltd. Newsgroups: comp.lang.c++ Date: Sun, 19 Jun 2011 11:42:56 -0400 Message-ID: <2011061911425631676-pete@versatilecodingcom> References: <4dfd95d3$0$2848$7b1e8fa0@news.nbl.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: Conversion of a number from string to vector User-Agent: Unison/2.1.4 Lines: 28 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-TGXDbIV9jZjjIQYWj9QZUua1h6PU9p0y2vRCrabNm3a33v3EqnUEaMWx57shEMc3iRmq/f2Y01CKIz9!Y0tKhoNzmv5rtT0ohcI8IfXcIDRGh2kxAN2OgWMADaOMQ6cvH84C70vNaL/8eubKNI4VmFub X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2123 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:6909 On 2011-06-19 07:13:27 -0400, Anonymous said: > > It's basically what I had done initially (see my previous thread). But > I would prefer base B, where B is power of two, not of 10, to profit by > all the possibile bits of the integer. > Use an unsigned int, and represent the values in base UINT_MAX + 1. That uses all the bits. To convert a text string, just use the obvious approach: set the current value to 0 set the current position in the string to the leftmost character while the character at the current position is in '0'..'9' multiply the current value by 10 add the value represented by the digit to the current value move the current position one place to the right Try it with pencil and paper a few times to get the feel of it. -- Pete Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The Standard C++ Library Extensions: a Tutorial and Reference (www.petebecker.com/tr1book)