Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

1er Komplement

fujitsufan
2009-10-28
2009-10-29
  • fujitsufan - 2009-10-28

    Hallo,

    ich versuche das 1er Komplement einer Variablen zu erzeugen.

    In C/C++ ganz einfach: value = ~value;

    In ICE61131 wohl nicht.

    Also: Aus 2#10010001 soll 2#01101110 werden.

    Muss ich das mühselig mit Bitposition ermitteln, Bit auslesen, Bit neu in die Variable schreiben, machen oder gibt es hierfür ´ne Funktion.

    Oscat hat die oscat260.lib. Ist da eine solche Funktion drin, wenn ja wie heißt diese?

    Vielen Dank!

    fujitsufan

     
  • J Schohaus - 2009-10-28

    Hallo

    ist kein Problem not kann auch auf WORD oder Byte benutz werden.

    wValue := NOT wValueIn ;

    mfG Jochen

     
  • fujitsufan - 2009-10-29

    Hallo,

    vielen Dank.

    Habs jetzt exclusiv verodert mit 16#FFFF.

    var1:=var2 XOR 16#FFFF;
    

    mfG.

    fujitsufan

     

Log in to post a comment.