Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Java puzzler Date: Wed, 11 May 2011 09:13:39 -0400 Organization: albasani.net Lines: 23 Message-ID: References: <4db69c13-878f-4806-adb2-a3c5adb1c48c@glegroupsg2000goo.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.albasani.net blEqriPa0dbxqI9c00EAnjDHskYipt7iuiTRh6YlEoIltVYluTp0P+LIX8Z86ijlujtg+uot+MukWWpE2GyAQmWIFDn4Upi7cv9gsSeHpSce0evV5RdkZ4eG8TDkR3uc NNTP-Posting-Date: Wed, 11 May 2011 13:13:39 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="bW3ZNKqGdKGzs6uv8AKhK97y/TRQ8EgJiPkrvLp0fXuW5UJhhQjzueLNwUscQHnkT7qbTCqkXC4yYLVUbiZKnuHq4MnquEvJ5TQa8OrCPxqUudXyc65v45rz5fPOcFxz"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 In-Reply-To: <4db69c13-878f-4806-adb2-a3c5adb1c48c@glegroupsg2000goo.googlegroups.com> Cancel-Lock: sha1:F2U3WMsMRjCQA2U3pxzZmsmt1R4= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3973 On 05/11/2011 04:44 AM, Gábor Bakos wrote: > It worked as specified. I just found unexpected that there is an implicit cast to the type of the variable. > For example there are not compiling: > int x = 0.5; > int y = 0; > y = y + 0.5; > These are no strange for me. > Although the thing that > int x = 0; > x += .5; > compiles without an error or warning it was unexpected for me. I do not see the usecase for the implicit cast there. (BTW the result I got was the correct 0 .) > Maybe it is just me who finds this strange. It is what it is. The Designers felt, obviously, that primitive numeric conversions shouldn't cause that kind of trouble. "Strange" is not an engineering assessment. It's some kind of vague crap that cannot be defended or refuted. Take a Zanax and calm down. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg