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!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 01 Jul 2011 22:28:20 -0500 Date: Fri, 01 Jul 2011 20:28:07 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 Newsgroups: comp.lang.java.help Subject: Re: Convert a String to Int: can I use toInt() instead of Integer.parseInt()? References: <521s0711i3d7bsc8620isi0oiidl91kujq@4ax.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 30 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 70.230.196.78 X-Trace: sv3-pz0QbV3cbVJiLm8bJ73axrxknJw66GG/yvxUqTvzRAkF1MjNRwQA2SKwi0WRD64TmnEt/OauWH+17ia!Vemzu0/O5nh0q9rGlx/sEWSFzuxEVONpzSTobRMEz5RRS6Uw0G49wplC07Is+TdOkXYP/Bu29Fd6!R9Es9WOTmlysJMW91mi7NcuYd1ogVm5VRYU5eQETazewGQ== 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: 2645 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.help:806 On 7/1/2011 8:06 PM, Eric Sosman wrote: > On 7/1/2011 1:53 PM, Thee Chicago Wolf [MVP] wrote: >> >> Doing homework for a programming course and we're given a 1000 digit >> String which we have to convert to integer, load into an array, and >> then find the largest product of a group of 5 integers. I know I can >> use the Integer.parseInt( ) method [...] > > You'd better hope that most of those digits are zeroes... > > It seems likely that the homework assignment is intended to make > you think about other ways than `int' or even `long' for representing > integers. Representations that can handle this sort of count-all-the- > protons-in-the-universe-if-every-actual-proton-were-a-universe-itself > kind of magnitude. Java provides at least two such things; I think > you're being encouraged to discover and use one or both of them. > >> but I wanted to play around with >> the toInt() method. From what I can gather, it's essentially the same >> thing...basically the opposite to the toString() method. So, I've >> tried a few things and I can't get it to work the way I want. ... > Check with whoever provided the NumberUtils class. It doesn't > come with Java; somebody else must have written it. > org.apache.commons.lang.math.NumberUtils does have a toInt method, but it is not particularly useful for this problem, because it returns an int. Patricia