Return-Path: X-Original-To: apmail-groovy-users-archive@minotaur.apache.org Delivered-To: apmail-groovy-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D750C1853C for ; Fri, 9 Oct 2015 19:18:31 +0000 (UTC) Received: (qmail 9945 invoked by uid 500); 9 Oct 2015 19:18:31 -0000 Delivered-To: apmail-groovy-users-archive@groovy.apache.org Received: (qmail 9546 invoked by uid 500); 9 Oct 2015 19:18:31 -0000 Mailing-List: contact users-help@groovy.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.incubator.apache.org Delivered-To: mailing list users@groovy.incubator.apache.org Received: (qmail 9421 invoked by uid 99); 9 Oct 2015 19:18:31 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Oct 2015 19:18:31 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id B89F2C172D for ; Fri, 9 Oct 2015 19:18:30 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1 X-Spam-Level: * X-Spam-Status: No, score=1 tagged_above=-999 required=6.31 tests=[KAM_LIVE=1, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id eZ3d7X5dOwBp for ; Fri, 9 Oct 2015 19:18:21 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 664F223060 for ; Fri, 9 Oct 2015 19:18:21 +0000 (UTC) Received: from [192.168.1.3] ([85.180.97.166]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0MWSwU-1a54V43uZu-00XeuM for ; Fri, 09 Oct 2015 21:18:13 +0200 Subject: Re: Math Operations To: users@groovy.incubator.apache.org References: <5C676E6359909E478C7B811BDB48CA3541A221@CWWAPP478.windstream.com> <56180B80.2050305@gmx.org> <5C676E6359909E478C7B811BDB48CA3541A26C@CWWAPP478.windstream.com> From: Jochen Theodorou Message-ID: <56181317.5030708@gmx.org> Date: Fri, 9 Oct 2015 21:18:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <5C676E6359909E478C7B811BDB48CA3541A26C@CWWAPP478.windstream.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:wCFt2U1IJKHWAIg3m2yuUneJc8K84M1OrxrhcHA7sApI4j2gKfd l7Aoer5Y5+IKD4QBRQjpmrYxKevtKHGcJ9hh3DU+2+Uik/CJRXQWqgAC3/nCUwADAio9xP8 IbP6B8WpIwF9oBxITWCUQViME0qEFNn8kevKPEmnzbEmXNqcoRTK7ZgwEx2+hZvO5B5sEqS B1Q3U8qKd1gE6qXhzKK1w== X-UI-Out-Filterresults: notjunk:1;V01:K0:JK7J2DYQgTk=:qL/UENlYewteCvMnpiffd6 8ryIThesk7W8Hm/7M50pUYn96db4n48gEfMWcZE9LNoepQxlHWDR+aNnMMSFVta722khDX+ty 7G1KphOiL/eX1DBO5j2nU6onL1vAPjhswxySw25pgbKLhhzQToWN28bh7CiegyBfNdXvL0gb/ dPzBNG5oNBJSgemagKOzfb+o+J3a/+za3orKbyZMPsVZ/aZifHTG5KJGNE+RvqtrHe3S8hSzt cg/jN+QdbLq1SEz3MWnlicV4uaHENirTx5axN5I/ArevCjpPtkLSQ2AsaC5GJOOfBeIfkUEMI HR2Ionrx42AXe/draRlBip1C/MvKMLf2jG8i1v+rhKEOiyQJv7HVdVWKt936pqqWDAHaHJW1M lV87B2UU4EMaiJo4E2/cfj54mB2x15GmDwBAMMBOkhmo18zG7/ZKqYe8OB+OAVCFgMb+9X3cq i7zCapECZM7OUiUmV8SsSX5EeN85c0lJyAKIQaWeRhps6ysr4XZYzZB4Kf02KxT0gSkmdYsH3 Xrl7BWalb+ZcwV/mRah5LTvIDXFdMYrXwEMKINXvfow4xau85OHFl6jO9lTkLc1nszq2HfZpg hKbGo3H5752pbHvUJYWKDk7vPRqBVmMsHL8Av+HTf6OXmZqnAUCNU8MILUL929UpFaQFmhJAy TWZGzXMFPzvhwZMdU+ytSnNH1GDcQd/GfyrSAZhBmukf8TJxU+BMCXQdKWl/wMJ22FHovps4+ gZ45L4zVq++nbbDn+nq0oNYjdfnYKd0t6vAXtTNlqX2sOXShlrC6E1i76ns2XIJgQPINm2DrO q76mbo4 Am 09.10.2015 um 20:55 schrieb Winnebeck, Jason: > OK, so int + BigDecimal is a bug in documentation then. > > I am using Groovy Shell (2.4.3, JVM: 1.8.0_45), and in that I run this: > > groovy:000> println (((byte)1 + (short)1).class) > class java.lang.Byte > ===> null > groovy:000> println ((byte)1 + (short)1) > 2 > ===> null > > I wondered if Groovy was somehow picking the "smallest" type, because byte + short -> byte makes no sense at all unless Groovy was looking at the result. However, this doesn't look good at all: > groovy:000> println ((byte)1 + (short)700) > -67 > > It looks like it really is doing the math as bytes. What version of Groovy are you using where it works? I just checked several version and you are right. This used to happen between 1.7.0 and 2.4.3 Always interesting to see a long term bug, nobody has bothered reporting before or went unnoticed. Anyway, 1.6.x and older versions behave right, as does 2.4.4. It also means we have a lot of versions in which primopts (Groovy 1.8.0+) and normal Groovy do behave different.... as well as static compilation and some versions of indy. bye blackdrag -- Jochen "blackdrag" Theodorou blog: http://blackdragsview.blogspot.com/