Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#6842 closed defect (fixed)

[with patch, positive review] ordinal_str giving wrong answers for 111, 112, 113

Reported by: SimonKing Owned by: somebody
Priority: minor Milestone: sage-4.1.2
Component: basic arithmetic Keywords: ordinals
Cc: Merged in: Sage 4.1.2.alpha0
Authors: Simon King Reviewers: Adam Webb
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

The following is incorrect, if I am not mistaken (but I am not a native speaker):

sage: n = 113
sage: n.ordinal_str()
'113rd'
sage: n = 112
sage: n.ordinal_str()
'112nd'
sage: n = 111
sage: n.ordinal_str()
'111st'

With my patch, one gets

sage: n = 111
sage: n.ordinal_str()
'111th'
sage: n = 112
sage: n.ordinal_str()
'112th'
sage: n = 113
sage: n.ordinal_str()
'113th'

while one still has

sage: n = 121
sage: n.ordinal_str()
'121st'
sage: n = 122
sage: n.ordinal_str()
'122nd'
sage: n = 123
sage: n.ordinal_str()
'123rd'

Attachments (1)

ordinal_str.patch (1.2 KB) - added by SimonKing 12 years ago.
Fixing ordinal_str for numbers of the form n*100+11, n*100+12, n*100+13

Download all attachments as: .zip

Change History (4)

Changed 12 years ago by SimonKing

Fixing ordinal_str for numbers of the form n*100+11, n*100+12, n*100+13

comment:1 Changed 12 years ago by awebb

  • Reviewers set to Adam Webb
  • Summary changed from [with patch, needs review] ordinal_str giving wrong answers for 111, 112, 113 to [with patch, positive review] ordinal_str giving wrong answers for 111, 112, 113

Looks good to me. It passes unit tests and the documentation builds correctly.

Adam

comment:2 Changed 12 years ago by mvngu

  • Merged in set to Sage 4.1.2.alpha0
  • Resolution set to fixed
  • Status changed from new to closed

comment:3 Changed 12 years ago by cremona

I came along to review this only to find that I was too late. Thanks for fixing the bug (which was mine).

Note: See TracTickets for help on using tickets.