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

Char and int comparison #7

Open
616slayer616 opened this issue Jul 18, 2019 · 5 comments
Open

Char and int comparison #7

616slayer616 opened this issue Jul 18, 2019 · 5 comments

Comments

@616slayer616
Copy link
Contributor

616slayer616 commented Jul 18, 2019

Line 51 is never true for all the examples I put into it.

if (ca == 0 && cb == 0) {

Is it supposed to compare with 0 (space) or with 48 (0)?

if (ca == '0' && cb == '0') {

@616slayer616
Copy link
Contributor Author

The condition cannot evaluate to true because of

if (!Character.isDigit(ca) && !Character.isDigit(cb)) {

If both ca and cb are 0 (space, non-digit) bias will be returned.

So L51 is either redundant or should be changed to check for 48 or '0' respectively

@paour
Copy link
Owner

paour commented Jul 18, 2019

The line is indeed redundant: if both ca and cb are 0, then neither is a digit.

@616slayer616
Copy link
Contributor Author

Thank you for the clarification

@paour
Copy link
Owner

paour commented Jul 18, 2019

Fixed by #9

@paour paour closed this as completed Jul 18, 2019
@616slayer616
Copy link
Contributor Author

This is the wrong issue for PR #9

I have no PR for the redundancy issue because I was unsure.

PR #9 is for Issue #1

@paour paour reopened this Jul 18, 2019
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