Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of Built-In Methods for Primitive Math operations #7050

Closed
4 tasks done
harishwar-babu opened this issue Feb 28, 2024 · 1 comment
Closed
4 tasks done

Addition of Built-In Methods for Primitive Math operations #7050

harishwar-babu opened this issue Feb 28, 2024 · 1 comment
Labels
type=addition A new feature

Comments

@harishwar-babu
Copy link

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?

ExisitingFeature.txt

3. What would that same code look like if we added your feature?

NewFeature.txt

(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

use-case.txt

Packages

com.google.common.math

Checklist

@harishwar-babu harishwar-babu added the type=addition A new feature label Feb 28, 2024
@cpovirk
Copy link
Member

cpovirk commented Feb 28, 2024

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.

@cpovirk cpovirk closed this as completed Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type=addition A new feature
Projects
None yet
Development

No branches or pull requests

2 participants