🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.pl.comp.lang.csharp
Article #9596

Re: operacje na bitach

#9596
From: Paweł
Date: Tue, 25 Oct 2005 15:16
33 lines
1384 bytes
Paweł wrote:

> lub:
> 
> int i = ...
> byte b = (byte)(i ^ 0xff);

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
*/
}
Technical Details
Message-ID: <djli8q$qrs$1@achot.icm.edu.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news2.icm.edu.pl!not-for-mail
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>

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 17:16:39 +0200
Organization: http://news.icm.edu.pl/
Lines: 34
Message-ID: <djli8q$qrs$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>
NNTP-Posting-Host: chello062179052145.chello.pl
Mime-Version: 1.0
X-Trace: achot.icm.edu.pl 1130253402 27516 62.179.52.145 (25 Oct 2005 15:16:42 GMT)
X-Complaints-To: abuse@icm.edu.pl
NNTP-Posting-Date: Tue, 25 Oct 2005 15:16:42 +0000 (UTC)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit