Repository navigation
Give ordinal of a whole float the same suffix as its string form - #291
Open
FatmaMahmoudR wants to merge 1 commit into
Open
FatmaMahmoudR wants to merge 1 commit into
FatmaMahmoudR wants to merge 1 commit into
Conversation
FatmaMahmoudR
marked this pull request as ready for review
October 22, 2026 15:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #192.
ordinaltakes the suffix of a decimal number from its last digit, soordinal("1.0")is"1.0th". A float holding a whole number went down a separate path that used its integer value instead:Now any number with a decimal point uses its last digit, so
ordinal(1.0) == ordinal("1.0") == "1.0th", the same way the existing test hasordinal(1.1) == ordinal("1.1"). A float's ordinal now always matches its string's, including large floats Python writes in scientific notation, such as1.1e+21.For the other case in the issue,
ordinal("1."), there's no digit after the point to take the suffix from, so it now raisesBadNumValueErrorinstead of returning"1.st". If you'd rather keep"1.st", I can put that branch back.With both special cases gone, the branching in
ordinalcomes down to one line.