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

(1.2.17) Rational.java #11

Open
emergencyd opened this issue Mar 27, 2020 · 1 comment
Open

(1.2.17) Rational.java #11

emergencyd opened this issue Mar 27, 2020 · 1 comment

Comments

@emergencyd
Copy link

emergencyd commented Mar 27, 2020

在判断是否overflow时,int值好像本身就不会超过max和min,所以判断a + b < MAX这种是不是并不能得到想要的效果?
其次,min应该是2^31,所以是-2147483648,不是-2147483647;

我的想法就是,比如ab>0且a > 0,根据a + b <= max,判断b是否符合b <= max - a...不知道这样是否可以

另外minus和divide也需要判断一下overflow吧

@jimmysuncpt
Copy link
Owner

jimmysuncpt commented Jun 24, 2020

改了一下,可以 review 一下看看有没有问题:80f5deb & dc44bdb
@emergencyd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants