amelentev / java-oo

Java Operator Overloading
http://amelentev.github.io/java-oo/
268 stars 31 forks source link

support ^ operator with (double,double) arguments #52

Open ghost opened 7 years ago

ghost commented 7 years ago

it should map to Math.pow(double,double) etc... or does this already work somehow?

StefanLobbenmeier commented 4 years ago

Sorry for answering on such an old issue. The operator ^ is already used in java for bitwise xor. Example:

        assert (true ^ false) == true;
        assert (true ^ true) == false;
        assert (0b1111 ^ 0b0100) == 0b1011;

For double and float this operator currently does not apply. Still adding this (besides the question whether this is doable) will lead to confusion, so I would not like having this.

In python there is a different operator (**) that is used for exponentiation. Adding this to java might make sense, although I am not sure if this can be done by this plugin.

StefanLobbenmeier commented 4 years ago

I just checked the code - my first guess would be to add an operator to the map here https://github.com/amelentev/java-oo/blob/ea44e927c01d8d228c7e193ceda7b4735eceb584/javac-oo-plugin/src/main/java/javaoo/OOMethods.java#L36

and check if it "just works".