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

Fixed the number ranges for short and ushort #1756

Closed
wants to merge 1 commit into from

Conversation

bencarlton
Copy link

Following the previous version of the chart will result in failed unit tests.

Following the previous version of the chart will result in failed unit tests.
@ErikSchierboom
Copy link
Member

This can't be correct, as the 0 to 32_768 range is now unrepresented. There might be something wrong with the tests.

@bencarlton
Copy link
Author

In my proposed change 0 to 32_767 range is encapsulated in the the range for the short type which goes from -32_768 to 32_767 and 32_768 is included in the range for the ushort type. If this is not the intention, then there are two tests that are incorrect, ToBuffer_upper_short and ToBuffer_Zero, as the former expects Int16.MaxValue (aka short.MaxValue) to be identified as a short but the table in the exercise identifies it as a ushort and the latter expects 0 to be identified as a short but the table identifies it as a ushort.

@ErikSchierboom
Copy link
Member

I think in this case the tests are wrong. To me, the table looks sane. If the tests aren't, we should fix the tests (and the exemplar solution). Do you want to do that?

@bencarlton
Copy link
Author

IMHO the proposed revision to the table better fits the pattern for the other signed and unsigned number types, i.e. using int for for ranges of both positive and negative numbers instead of only using it for negative numbers and uint for positive numbers.

However, if you disagree I can submit a pull request correcting the tests and the exemplar solution.

@ErikSchierboom
Copy link
Member

IMHO the proposed revision to the table better fits the pattern for the other signed and unsigned number types, i.e. using int for for ranges of both positive and negative numbers instead of only using it for negative numbers and uint for positive numbers.

It does. I just think that the current instructions are fairly confusing. What do you think of exclusively using unsigned types for all the positive integers, and signed types for the negative integers? IMHO that would make a lot more sense.

@bencarlton
Copy link
Author

bencarlton commented Oct 28, 2021

In that case, should it use ulong instead of long for positive numbers greater than uint.MaxValue? That would be introducing a new numeric type that isn't currently covered in the exercise.

@ErikSchierboom
Copy link
Member

In that case, should it use ulong instead of long for positive numbers greater than uint.MaxValue? That would be introducing a new numeric type that isn't currently covered in the exercise.

It should. The exercise's introduction mentions ulong, so you're free to use it.

@ErikSchierboom
Copy link
Member

Superseded by #1796

Thanks for the effort @bencarlton!

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

Successfully merging this pull request may close these issues.

2 participants