This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients LambertDW, ajaksu2, dingo, giampaolo.rodola, gvanrossum, jyasskin, loewis, mark.dickinson, orsenthil, rhettinger
Date 2009-01-28.09:26:32
SpamBayes Score 9.161191e-06
Marked as misclassified No
Message-id <1233134794.48.0.501568443722.issue4707@psf.upfronthosting.co.za>
In-reply-to
Content
For myself, I strongly prefer that round(int, int) return an integer in 
Python 3.x.  Here ar\
e three reasons:

(1) Interoperability with Decimal (and, to a lesser extent, Fraction): 
the decimal module is\
 carefully designed so that Decimals interact well with integers.  If 
round(int, int) return\
s an integer then someone working with Decimals can use round freely, 
without worrying about\
 whether his or her numbers are actually integers or Decimals.  If 
round(int, int) returns a\
 float then that someone is likely to get a nasty shock doing 
round(Decimal, int) when it tu\
rns out that the Decimal was actually just a plain integer.

(2) Accuracy:  currently, for example, we have

>>> round(10**16+1, 0)
10000000000000000.0

If the return type is changed to int, there's no need for this loss of 
accuracy.

(3) Consistency:  in 3.x, round(my_decimal, n) returns a Decimal;  
round(my_fraction, n) ret\
urns a Fraction.  That is, for all Python's numeric types other than 
int, the value returned\
 from two-argument round has the same type as the first argument.
History
Date User Action Args
2009-01-28 09:26:34mark.dickinsonsetrecipients: + mark.dickinson, gvanrossum, loewis, rhettinger, orsenthil, giampaolo.rodola, ajaksu2, jyasskin, LambertDW, dingo
2009-01-28 09:26:34mark.dickinsonsetmessageid: <1233134794.48.0.501568443722.issue4707@psf.upfronthosting.co.za>
2009-01-28 09:26:33mark.dickinsonlinkissue4707 messages
2009-01-28 09:26:32mark.dickinsoncreate