1Lingua::EN::Numbers::OrUdsienratCeo(n3t)ributed Perl DocLuimnegnutaa:t:iEoNn::Numbers::Ordinate(3)
2
3
4

NAME

6       Lingua::EN::Numbers::Ordinate -- go from cardinal number (3) to ordinal
7       ("3rd")
8

SYNOPSIS

10         use Lingua::EN::Numbers::Ordinate;
11         print ordinate(4), "\n";
12          # prints 4th
13         print ordinate(-342), "\n";
14          # prints -342nd
15
16         # Example of actual use:
17         ...
18         for(my $i = 0; $i < @records; $i++) {
19           unless(is_valid($record[$i]) {
20             warn "The ", ordinate($i), " record is invalid!\n";
21             next;
22           }
23           ...
24         }
25

DESCRIPTION

27       There are two kinds of numbers in English -- cardinals (1, 2, 3...),
28       and ordinals (1st, 2nd, 3rd...).  This library provides functions for
29       giving the ordinal form of a number, given its cardinal value.
30

FUNCTIONS

32       ordinate(SCALAR)
33           Returns a string consisting of that scalar's string form, plus the
34           appropriate ordinal suffix.  Example: ordinate(23) returns "23rd".
35
36           As a special case, ordinate(undef) and ordinate("") return "0th",
37           not "th".
38
39           This function is exported by default.
40
41       th(SCALAR)
42           Merely an alias for "ordinate", but not exported by default.
43
44       ordsuf(SCALAR)
45           Returns just the appropriate ordinal suffix for the given scalar
46           numeric value.  This is what "ordinate" uses to actually do its
47           work.  For example, ordsuf(3) is "rd".
48
49           Not exported by default.
50
51       The above functions are all prototyped to take a scalar value, so
52       ordinate(@stuff) is the same as "ordinate(scalar @stuff)".
53

CAVEATS

55       * Note that this library knows only about numbers, not number-words.
56       ordinate('seven') might just as well be ordinate('superglue') or
57       ordinate("\x1E\x9A") -- you'll get the fallthru case of the input
58       string plus "th".
59
60       * As is unavoidable, ordinate(0256) returns "174th" (because ordinate
61       sees the value 174). Similarly, ordinate(1E12) returns
62       "1000000000000th".  Returning "trillionth" would be nice, but that's an
63       awfully atypical case.
64
65       * Note that this library's algorithm (as well as the basic concept and
66       implementation of ordinal numbers) is totally language specific.
67
68       To pick a trivial example, consider that in French, 1 ordinates as
69       "1ier", whereas 41 ordinates as "41ieme".
70

SEE ALSO

72       Lingua::EN::Inflect provides an "ORD" function, which returns the
73       ordinal form of a cardinal number.
74
75       Lingua::EN::Number::IsOrdinal provides an "is_ordinal" function, which
76       returns true if passed an ordinal number.
77
78       Lingua::EN::Numbers provides function num2en_ordinal() which will take
79       a number and return the ordinal as a word.  So 3 will result in
80       "third".
81

REPOSITORY

83       <https://github.com/neilb/Lingua-EN-Numbers-Ordinate>
84
86       Copyright (c) 2000 Sean M. Burke.  All rights reserved.
87
88       This library is free software; you can redistribute it and/or modify it
89       under the same terms as Perl itself.
90

AUTHOR

92       Sean M. Burke "sburke@cpan.org"
93
94       This has been maintained by Neil Bowers (NEILB) since 2014.
95
96
97
98perl v5.36.0                      2023-01-20  Lingua::EN::Numbers::Ordinate(3)
Impressum