One of my little projects that im working on inbetween work, is taking an version of an existing project in delphi, and creating it as a Java Applet.
So initially im converting some of the algorithms etc into java, however, i came across this :
if (Ord(Code[i]) - MinValue - HalfRange < HalfRange)
and (Ord(Code[i]) - MinValue - HalfRange >= 0) then
Code[i] := Chr(Ord(Code[i]) - HalfRange)
else
if Ord(Code[i]) >= MinValue then
Code[i] := Chr(Ord(Code[i]) + HalfRange);
now, i understand most of that code-wise, but when it does
Code:
if (Ord(Code[i]) - MinValue - HalfRange < HalfRange)
and
Code:
and (Ord(Code[i]) - MinValue - HalfRange >= 0) then
im running into some trouble understanding order of preference (i think)
basically there are 3 integers on the left, but i cant work out which order the maths is being carried out in, as there are two minus signs and no brackets anywhere. In java i would have put brackets to indicate how the maths was happening, but here there are non. Having spoken to the guy who wrote the code originally, im no closer to understand it as i know next to nothing about delphi.
the first appears to be
a - b - c < d
but is that
(a - (b+c)) < d
or
(a-(b-c)) < d ?
If i had a copy of delphi here i'd run a small program and check, but i dont.
Can anyone help ?