Hi sss555,
Sorry I missed your message about this the other day about this.
From reading your code I understand you have some point P, then 2*P = (xx, yy) while 4*P = (xx, yy). You then compute (a, b) = (xx/2, yy/2), and expect this to be equal to 2*P.
This won't be the case because "2*P" does not mean "the point whose coordinates are twice P's". It actually means P + P, where addition is defined according to the
elliptic curve group law.
To contrast, when you multiply coordinates by numbers, you are simply multiplying them modulo p. This can still be described as repeated addition, but this addition is ordinary arithmetic addition modulo p, nothing exotic.
Does this clarify things?
Andrew