🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.java
Article #153926

przesunięcie biotwe w Java - dziwny błąd

#153926
From: bigMamma
Date: Wed, 23 Oct 2013 12:22
15 lines
1540 bytes
wydawało mi się (przy moim ostatnim temacie), że przesunięcie bitowe działa prawidłowo.

Mam takie wyrażenie:
short w = (short) (((byte)dana) << x);

... String.format("%04X",w);

jeżeli dana zawiera (byte) 0x88
a x = 5

to otrzymuję F100

zamiast 1100

Jak mogę to zmienić, aby było poprawnie!
Technical Details
Message-ID: <fb7c6605-2b1d-4241-8bed-9caf7952f21f@googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!news.supermedia.pl!news.nask.pl!news.nask.org.pl!newsfeed.pionier.net.pl!news.glorb.com!i2no29164453qav.0!news-out.google.com!rn2ni118903pbc.1!nntp.google.com!o2no21619009qas.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Received: by 10.182.108.166 with SMTP id hl6mr509231obb.1.1382530947918;        Wed, 23 Oct 2013 05:22:27 -0700 (PDT)
X-Received: by 10.49.27.168 with SMTP id u8mr29175qeg.11.1382530947630; Wed, 23 Oct 2013 05:22:27 -0700 (PDT)
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!news.supermedia.pl!news.nask.pl!news.nask.org.pl!newsfeed.pionier.net.pl!news.glorb.com!i2no29164453qav.0!news-out.google.com!rn2ni118903pbc.1!nntp.google.com!o2no21619009qas.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: pl.comp.lang.java
Date: Wed, 23 Oct 2013 05:22:27 -0700 (PDT)
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=31.174.200.169; posting-account=S68uugoAAADAKFnRPdRLP91xa88xg3LE
NNTP-Posting-Host: 31.174.200.169
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fb7c6605-2b1d-4241-8bed-9caf7952f21f@googlegroups.com>
Subject: przesunięcie biotwe w Java - dziwny
 błąd
From: bigMamma <marcinchuc@gmail.com>
Injection-Date: Wed, 23 Oct 2013 12:22:27 +0000
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit