Opened 4 years ago
Closed 4 years ago
#9079 closed defect (bug) (fixed)
Documentation correction: absint()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.8 |
| Component: | General | Version: | 2.7 |
| Severity: | minor | Keywords: | documentation, has-patch |
| Cc: |
Description
Documentation currently states:
"Converts value to positive integer."
Should state:
"Converts value to nonnegative integer."
Attachments (1)
Change History (7)
- Owner changed from anonymous to mdawaffe
- Severity changed from normal to minor
- Status changed from new to assigned
- Version set to 2.7
"nonnegative" is "math" language :)
http://mathworld.wolfram.com/Nonnegative.html
http://en.wikipedia.org/wiki/Negative_and_non-negative_numbers
I have not heard "absolute integer" before.
It probably doesn't matter how the function actually works, as long as it never returns negative numbers.
Replying to mdawaffe:
I have not heard "absolute integer" before.
Agreed, that should have been something like "Converts an integer to it's absolute value." but nonnegative sounds better.
Note: See
TracTickets for help on using
tickets.

Wouldn't it be clearer to use the "math" language there: "Converts value to absolute integer."
Looking at how this is used, perhaps we need something different there. Currently absint(100) returns 100, absint(-100) returns 100 too but is used to filter various db IDs where -100 is an invalid value. Perhaps we need something like:
function absint( $maybeint ) { if ( intval( $maybeint ) < 1 ) return 0; return intval( $maybeint ); }