PROCEDURE BitXOR@1000000014(A@1000000000 : Integer;B@1000000001 : Integer) : Integer; VAR Pos@1000000002 : Integer; Tmp@1000000003 : Integer; i@1000000004 : Integer; ANeg@1000000006 : Boolean; BNeg@1000000007 : Boolean; BEGIN Pos := 1; Tmp := 0; IF A < 0 THEN BEGIN ANeg := TRUE; A := A - -2147483648; END; IF B < 0 THEN BEGIN BNeg := TRUE; B := B - -2147483648; END; FOR i := 1 TO 30 DO BEGIN IF (A MOD 2) <> (B MOD 2) THEN Tmp += Pos; Pos *= 2; A := A DIV 2; B := B DIV 2; END; // Bit31 IF (A MOD 2) <> (B MOD 2) THEN Tmp += Pos; // Bit32 IF ANeg XOR BNeg THEN Tmp := Tmp - 1073741824 - 1073741824; EXIT(Tmp); END;
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
It looks like it crashed because I'm doing around a hundred thousand XORs, this takes time ... lots of time ...
I thought I'd found an answer using a COM object but the RTC must take of the order of a quarter of a millisecond to make a single call to a COM object; that mounts up quickly too.
I suppose I'm going to have to shift more code into the COM object, of course that means piping a BLOB through the COM object too. Oh hum, I'll wait a little while before I dig out the VB6 compiler again.
TVision Technology Ltd
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
The only time I ever needed to was to write a game. :whistle:
Just a little bit of SHA1 with some blowfish flavouring.
TVision Technology Ltd
In a request form, I had 6 textcontrols (grouped in pairs) that I wanted to make editable/uneditable under some conditions. One, and only one, of the pairs should be editable at the time.
I decided to create a procedure, to call it when needed. I wanted to be sure that only one of the bool parameters where set to TRUE.
Here you have the code that helped me implement my own XOR condition:
Salut!
Author of the book Implementing Dynamics NAV 2013
Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.
Nav, T-SQL.
I found it in the GetCaptionClass on form 403 (Purch. Order Statistics)
|To-Increase|
I did not found any reference to XOR in the help, so I thought it didn't exist as a command.
I changed my code, now it looks like this
Salut!
Author of the book Implementing Dynamics NAV 2013
Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.
More FYI, that operator has been present since the early days, eg: version 2 or earlier. It only works on booleans though so is logically equivalent to the "<>" operator which makes it useless as "<>" is normally considered a lot more obvious.
TVision Technology Ltd
It looks like you're not taking note of negative numbers properly, an XOR of 0 and -1 should be -1, your result is 0.
TVision Technology Ltd