Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #31858
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: elementary loops |
| Date | Fri, 26 Jun 2015 08:26:33 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 34 |
| Message-ID | <mmjgbb$him$1@dont-email.me> (permalink) |
| References | <loops-20150622181350@ram.dialup.fu-berlin.de> <mmiu9s$pa$1@gwaiyur.mb-net.net> <slrnmoq6pg.uoi.avl@login.logic.tuwien.ac.at> <mmjdme$543$1@gwaiyur.mb-net.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-15; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Fri, 26 Jun 2015 12:25:15 +0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="18006"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/uV0Bi10fr/Pfe5+eN9y5m" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
| In-Reply-To | <mmjdme$543$1@gwaiyur.mb-net.net> |
| Cancel-Lock | sha1:OTlt95JfZy+Te+uz4DXv3C9UJF0= |
| Xref | csiph.com comp.lang.java.programmer:31858 |
Show key headers only | View raw
On 6/26/2015 7:39 AM, Marcel Mueller wrote:
> On 26.06.15 11.26, Andreas Leitgeb wrote:
>>>> { public static void main( final java.lang.String[] args )
>>>> { short i = -1;
>>>> int j = -1;
>>>> for( int k = 0; k < 65; ++k ){ i >>>= 1; j <<= 32; }
>>
>> The short i is promoted to int, then the MSB ("sign"-bit) zeroed,
>> then converted back to short, where it's still -1
>
> In this case the >>> operator is meaningless for short int and there is
> no option to perform this operation except for emulating the behavior by
> other bit functions or types. The same applies to byte as well.
> Of course, this is only another side effect of the missing unsigned types.
> Is this guaranteed by the language or just implementation defined?
The former. The relevant bits of the Java Language Specification
<http://docs.oracle.com/javase/specs/jls/se8/html/index.html> are
- 15.26.2 "Compound Assignment Operators"
- 15.19 "Shift Operators"
- 5.6.1 "Unary Numeric Promotion"
- 5.1.2 "Widening Primitive Conversion"
- 15.16 "Cast Expressions" (implied by 15.26.2)
- 5.1.3 "Narrowing Primitive Conversion"
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: elementary loops Marcel Mueller <news.5.maazl@spamgourmet.org> - 2015-06-26 09:17 +0200
Re: elementary loops Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2015-06-26 09:26 +0000
Re: elementary loops Marcel Mueller <news.5.maazl@spamgourmet.org> - 2015-06-26 13:39 +0200
Re: elementary loops Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-06-26 08:26 -0400
Re: elementary loops Arne Vajhøj <arne@vajhoej.dk> - 2015-06-28 20:12 -0400
Re: elementary loops Marcel Mueller <news.5.maazl@spamgourmet.org> - 2015-06-29 19:50 +0200
Re: elementary loops Arne Vajhøj <arne@vajhoej.dk> - 2015-06-29 13:58 -0400
csiph-web