"and" löscht Vorzeichenbit

robert
Benutzer
Avatar
Gender: n/a
Location: Hildesheim / Deutschland
Posts: 249
Registered: 04 / 2006
Subject:

"and" löscht Vorzeichenbit

 · 
Posted: 15.07.2010 - 11:20  ·  #1
Hallo,
ein "i and integer(%1111111111111111)" löscht das Vorzeichenbit. Bug oder Feature?

Robert

Code
program bla;

{$NOSHADOW}
{ $WG}                     {global Warnings off}

Device = mega128, VCC=5;
{ $BOOTRST $1F000}         {Reset Jump to $1F000}

Import SysTick, SerPort;

From System Import Float, Fix64;


Define
  ProcClock      = 16000000;       {Hertz}
  SysTick        = 10;             {msec}
  StackSize      = $0100, iData;
  FrameSize      = $0100, iData;
  SerPort        = 57600, Stop2;    {Baud, StopBits|Parity}
  RxBuffer       = 8, iData;
  TxBuffer       = 8, iData;

Implementation

{$IDATA}

const

type

var
  i : integer;
  
begin
  EnableInts;

  i := -123;
  i := i and integer(%11111111 11111111);  //Löscht das Vorzeichenbit. Warum?
  WriteLn(SerOut, 'i = ' + IntToStr(i:8) + '  ' + IntToBin(i));

  WriteLn(SerOut);
  
  i := -123;
  i := integer(word(i) and word(%11111111 11111111)); //So geht's
  WriteLn(SerOut, 'i = ' + IntToStr(i:8) + '  ' + IntToBin(i));
  
end bla.
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: "and" löscht Vorzeichenbit

 · 
Posted: 15.07.2010 - 15:01  ·  #2
Hallo Robert,

Ihr Hobby ist offensichtlich Compiler Bugs zu finden :-)
Es ist ein Bug. Update am WE.

rolf
robert
Benutzer
Avatar
Gender: n/a
Location: Hildesheim / Deutschland
Posts: 249
Registered: 04 / 2006
Subject:

Re: "and" löscht Vorzeichenbit

 · 
Posted: 15.07.2010 - 15:19  ·  #3
Hallo Rolf,
Quote by rh

Ihr Hobby ist offensichtlich Compiler Bugs zu finden :-)

:lol:
Bei der hohen Trefferquote mag man das meinen. Aber nein, Bugs finden macht mir keinen Spass. Es kostet so viel Zeit. Die eigentlich ganz einfache Sache, einen LM76 auszulesen, hat mich fast zur Verzweiflung gebracht, als ich mit Kältespray anfing und keine negativen Temperaturen erhielt.

Robert
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   66   80 · Page-Gen-Time: 0.021087s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI