Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: boolean to int : was char to decimal Date: Fri, 06 May 2011 09:00:25 -0400 Organization: A noiseless patient Spider Lines: 28 Message-ID: References: <92ea64F3avU1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 6 May 2011 12:58:20 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="66+B4XK2fUYI7mQKoMaOgA"; logging-data="14844"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Hx4EPnpkBx1WKSgQmygITsIMMDuGgtt8=" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 In-Reply-To: Cancel-Lock: sha1:cGpX0lnyDuDoJIhiYDZTXH2evjk= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3678 On 05/05/2011 04:03 AM, Lawrence D'Oliveiro wrote: > In message, Ian Shef wrote: > > Funny, they could do all this for char, but not for boolean. Recently I was translating a piece of C++ code to Java. I'm wondering how others might make this translation. Thanks, JSH. double d2; double d3; double e; C++ test: int test = (int(d2 > e) << 1) + int(d3 > e); Java test: int t = d2 > e ? 1<<1 : 0; int test = d3 > e ? t+1 : t; switch(test) { case(0): case(1): case(2): case(3): }