AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Bitoperationen

Ein Thema von Dunkelbunt27 · begonnen am 21. Feb 2011 · letzter Beitrag vom 26. Feb 2011
 
Benutzerbild von Aphton
Aphton

Registriert seit: 31. Mai 2009
1.198 Beiträge
 
Turbo Delphi für Win32
 
#36

AW: Bitoperationen

  Alt 25. Feb 2011, 20:02
Eigentlich setzt man doch ein Bit mit:
Code:
attribut:= attribut or $01;
Und entfernt es wieder mit:
Code:
attribut := attribut and not $02;
Oder?

Ich mache das wie folgt:
Button1:
Code:
attribut:= attribut or $01;
attribut := attribut and not $02;
Byte = 1

Button2:
Code:
attribut:= attribut or $02;
attribut := attribut and not $01;
Byte = 00000011
Ich verstehe nicht, warum du immernoch solche Fehler machst:
Code:
// "Eigentlich setzt man doch ein Bit mit:"
attribut:= attribut or $01;
// "Und entfernt es wieder mit:"
attribut := attribut and not $02;
Byte = 1
Im Grund hast du ja schon Recht mit dem Entfernen aber du entfernst nicht das gesetzte Bit, sondern das zweite Bit.
Sagen wir einmal, Attribut habe den Wert 0.

attribut:= attribut or $01 :
Code:
   00000000
or 00000001
-----------
   00000001
attribut := attribut and not $02;
Code:
not 2:
2     = 00000010
not 2 = 11111101

    00000001
and 11111101
------------
    00000001

Du erhälts also 1 binär, was 2^0 Dezimals entspricht,
das Erkennen beginnt, wenn der Erkennende vom zu Erkennenden Abstand nimmt
MfG
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:16 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz