Article View: alt.pl.comp.lang.csharp
Article #9598Re: operacje na bitach
From: Paweł
Date: Tue, 25 Oct 2005 20:21
Date: Tue, 25 Oct 2005 20:21
39 lines
1638 bytes
1638 bytes
Hilarion wrote:
>> implementacja powyzszego zajmuje 9 bajtow ichnego kodu:
>>
>> public static byte foo(int x)
>> {
>> return (byte)(x ^ 0xff);
>> /*
>> IL_0000: ldarg.0
>> IL_0001: ldc.i4 255
>> IL_0006: xor
>> IL_0007: conv.u1
>> IL_0008: ret
>> */
>> }
>>
>> ale w sumie mozna to zrobic szybciej i latwiej (tylko 4 bajty kodu).
>>
>> public static byte bar(int x)
>> {
>> return (byte)(~x);
>> /*
>> IL_0000: ldarg.0
>> IL_0001: not
>> IL_0002: conv.u1
>> IL_0003: ret
>> */
>> }
>
>
> A co wychodzi z poniższego?
>
> public static byte bar(int x)
> {
> return ~((byte)x);
> }
błąd :)
error CS0029: Cannot implicitly convert type `int' to `byte'
Technical Details
Message-ID:
<djm43s$fsv$1@achot.icm.edu.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news2.icm.edu.pl!not-for-mailReferences:
<djkvmh$ugp$1@news.onet.pl> <djl2uc$bp5$1@atlantis.news.tpi.pl> <djl7bg$u30$1@news.onet.pl> <djl898$2pu$1@news.onet.pl> <djlgum$pf0$1@achot.icm.edu.pl> <djli8q$qrs$1@achot.icm.edu.pl> <djlv6s$sq0$1@news.onet.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news2.icm.edu.pl!not-for-mail From: Paweł <root@[127.0.0.1]> Newsgroups: alt.pl.comp.lang.csharp Subject: Re: operacje na bitach Date: Tue, 25 Oct 2005 22:21:15 +0200 Organization: http://news.icm.edu.pl/ Lines: 40 Message-ID: <djm43s$fsv$1@achot.icm.edu.pl> References: <djkvmh$ugp$1@news.onet.pl> <djl2uc$bp5$1@atlantis.news.tpi.pl> <djl7bg$u30$1@news.onet.pl> <djl898$2pu$1@news.onet.pl> <djlgum$pf0$1@achot.icm.edu.pl> <djli8q$qrs$1@achot.icm.edu.pl> <djlv6s$sq0$1@news.onet.pl> NNTP-Posting-Host: chello062179052145.chello.pl Mime-Version: 1.0 X-Trace: achot.icm.edu.pl 1130271676 16287 62.179.52.145 (25 Oct 2005 20:21:16 GMT) X-Complaints-To: abuse@icm.edu.pl NNTP-Posting-Date: Tue, 25 Oct 2005 20:21:16 +0000 (UTC) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit