Incorrect ordinal suffix when using Number::ordinal() with float values #54540
Unanswered
harry-fakir
asked this question in
Ideas
Replies: 1 comment
-
The current approach implicitly casts floats by accepting them and rounding by discarding. This results in inconsistent behavior: the ordinal suffix is determined using the last digit of the original (unrounded) value, while the displayed number follows standard rounding. Unfortunately, fixing this requires a judgement call. Given an input of 83.9, some possible solutions are:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Laravel Version
11.34.1
PHP Version
8.3.1
Database Driver & Version
No response
Description
Description
The
Number::ordinal()
helper method produces unpredictable ordinal suffixes when provided with float values, despite accepting both integers and floats as input.Current Behavior
When passing a float value, the method:
Example
Expected Behavior
The method should either:
NumberFormatter::ordinal()
only accepts integersTechnical Details
NumberFormatter::ordinal()
which only accepts integersAdditional Notes
This could lead to unexpected output in applications that deal with statistical or ranking data where float values are common inputs.
Steps To Reproduce
Beta Was this translation helpful? Give feedback.
All reactions