Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Gene Wirchenko Newsgroups: comp.lang.java.programmer Subject: Re: multi-line Strings Date: Wed, 19 Dec 2012 10:00:29 -0800 Organization: A noiseless patient Spider Lines: 44 Message-ID: <8304d85078s7fptda9mirjdgrkn6t2rbv2@4ax.com> References: <1rfmfoqs8bzc6.4pavkn8829dk$.dlg@40tude.net> <16v4yulqhdd19$.qhn9q6330idh$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="95789bcd602b4527561dc0cb1c85cae5"; logging-data="18727"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19EpL3lKRT5s/R58cNVAOf317YWBCo085c=" X-Newsreader: Forte Agent 4.2/32.1118 Cancel-Lock: sha1:+IMTJv3ZEwGkJ1SQ/Bxs+W/qwTk= Xref: csiph.com comp.lang.java.programmer:20564 On Tue, 18 Dec 2012 15:12:41 -0800, Gene Wirchenko wrote: >On Tue, 18 Dec 2012 10:54:08 -0800, Peter Duniho > wrote: > >>On Tue, 18 Dec 2012 06:34:02 -0400, Arved Sandstrom wrote: >> >>> Pete, I know where you're coming from, but Eric more accurately captured >>> the scenarios I was thinking of. >> >>His examples are exceptions to the rule, not demonstrations of a good rule. >> >>> Another example is the old-style and somewhat language-agnostic pseudocode >>> >>> round(d*100.)/100. >>> >>> for rounding to 2 decimal places (substitute other powers of ten for >>> rounding to less or more decimal places). [*] Here there is no meaning >>> for those constants other than TEN or a HUNDRED. >> >>Writing code like that is silly. You should use a proper "round()" method >>that takes as input the number of decimal places to use. > > Why? You are just going to have to raise 10 to the power of 2. >Not surprisingly, that is 100. > >>In either case, arguably the number of decimal places to round by should be >>declared itself as a constant. Writing "100" by itself tells the reader of >>the code nothing about why one is rounding to two decimal places, versus >>some other number. This is true whether you use a more descriptive, more >>functional "round()" method or go with the "*100, /100" approach. > > It is a common idiom. Outside computing, multiplying by 100 by >moving the decimal point two places to the left is understood by many, >including elementary school children. I did not get this right. It should be right and "right". Move the decimal point two places to the right. It is still true about the elementary school children. Sincerely, Gene Wirchenko