Autor Beitrag
Papperlapapp
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Do 27.11.08 11:19 
moin,

ich habe folgendes:

ausblenden Delphi-Quelltext
1:
2:
3:
a:byte;

a:= not(a);


wenn a:=1 was ist dann das Ergebnis? 0 oder 254?
Nersgatt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Do 27.11.08 11:23 
a:byte;

a := 1; // = 00000001
a:= not(a); // = 11111110

Also 254

Gruß,
Jens
freedy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 403
Erhaltene Danke: 1

Winows 7
Delphi XE
BeitragVerfasst: Do 27.11.08 11:25 
Hi

Ich würde sagen, dass das not logisch ist, nicht binär. Daher wäre das Ergebnis 0.
Nersgatt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Do 27.11.08 11:29 
user profile iconfreedy hat folgendes geschrieben Zum zitierten Posting springen:
Hi

Ich würde sagen, dass das not logisch ist, nicht binär. Daher wäre das Ergebnis 0.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.FormCreate(Sender: TObject);
var b : Byte;
begin
  b := 1;
  showmessage(intToStr(not b));
end;


Ergibt bei mir 254.

Gruß,
Jens
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 27.11.08 11:31 
NOT kann sowohl auf einen Binärwert angewendet werden, als auch auf einen Integer-Wert. Im ersten Fall ist es die logische Negation, im zweiten die bitweise Negation. Das funktioniert auch bei einigen anderen Operatoren wir OR und AND.

_________________
We are, we were and will not be.
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 27.11.08 11:32 
Das not wäre logisch, wenn a nicht byte, sondern boolean wäre.


Zuletzt bearbeitet von DeddyH am Do 27.11.08 11:35, insgesamt 1-mal bearbeitet
freedy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 403
Erhaltene Danke: 1

Winows 7
Delphi XE
BeitragVerfasst: Do 27.11.08 11:32 
user profile iconfreedy hat folgendes geschrieben Zum zitierten Posting springen:
Hi

Ich würde sagen, dass das not logisch ist, nicht binär. Daher wäre das Ergebnis 0.


EDIT: Okay, Delphi sagt mir etwas anderes. Ich denke, dass hängt dann wohl stark vom deklarierten Typ ab. Aber das habt ihr ja schon geschrieben. :-)
Papperlapapp Threadstarter
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Do 27.11.08 11:35 
danke