Addition of Built-In Methods for Primitive Math operations
harishwar-babu opened this issue · comments
Harish Babu commented
1. What are you trying to do?
- I would like to add a new feature that focus on performing addition of 2 numbers irrespective of type (int,int) or (long,long) or (short,short). that too with the help of bitwise operators(^,&).
- similarly for checking whether the number is even or odd. using & operator.
- Note: The above 2 features will not work for double/floating point numbers It will work only for whole/natural numbers.
- so, these are the above 2 features I would like to add to the Guava Math library.
2. What's the best code you can write to accomplish that without the new feature?
3. What would that same code look like if we added your feature?
(Optional) What would the method signatures for your feature look like?
// for addition of two numbers.
public int add(int value1,int value2);
public long add(long value1,long value2);
public short add(short value1,short value2);
//for even number check
public int isEven(int value);
public long isEven(long value);
public short isEven(short value);
Concrete Use Cases
Packages
com.google.common.math
Checklist
-
I agree to follow the code of conduct.
-
I have read and understood the contribution guidelines.
-
I have read and understood Guava's philosophy, and I strongly believe that this proposal aligns with it.
-
I have visited the idea graveyard, and did not see anything similar to this idea.
Chris Povirk commented
As discussed in #6982 (comment), the performance argument for the bitwise addition operations these is difficult to believe. For previous discussion of isEven
, see #1229.