Hi java coder here
im converting a program into delphi for a project
basicaly ive forgotten my whole delphi maths
soo
can anyone convert this into delphi

``(l1 & 0x2 ^ 0xffffffff) == -3;``

What is ^ for ?

It's an equality test.

(11 and \$2 xor \$FFFFFFFF) = -3

if I understand the syntax right

The question is a bit silly and incomplete (and quite old!), but deserves an answer for those looking for syntactical comparisons:

What the given example does:
&0x2 leaves only bit 1 intact (counting from bit 0)
^ 0xffffffff then sets all the 0 bits to 1's but inverts the results from the above bit 1
Now testing with -3 (which is 0x11111101) then simply says that bit 1 originally had to be a "1" now that it is inverted to "0" to make the comparison true.

So Delphi then is:
(l1 and \$2)

and the original java should've been:
(l1 & 0x2)
and eliminate all the other junk.

if the Op just wanted to see the equivalent (silly, broken, and incomplete) syntax in Delphi, it would look like this:

((l1 and \$2) xor \$ffffffff) = -3; //silly test for bit 1- TRUE if bit 1 is set... the trailing semicolon is out of place for any kind of real statement, but it matches the OP semicolon syntax.

more proper:
if (l1 and \$2 <> 0) then

or if just assigning a boolean result from this:

var myBool : boolean;
mybool := (0 <> (l1 and \$2)); // unlike C, boolean is not considered a type of integer in Delphi, so we do a logical operation to gain a boolean result

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.