Author mark.dickinson
Recipients facundobatista, mark.dickinson, rhettinger, skrah, terry.reedy
Date 2018-03-15.20:38:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1521146313.09.0.467229070634.issue33083@psf.upfronthosting.co.za>
In-reply-to
Content
Observed by Terry Reedy in the issue #25735 discussion (msg255479):

>>> factorial(decimal.Decimal(5.2))
120

This should be either raising an exception (either ValueError or TypeError, depending on whether we want to accept only integral Decimal values, or prohibit Decimal values altogether), or possibly returning an approximation to Gamma(6.2) (=169.406099461722999629...)

I'd prefer that we prohibit a Decimal input altogether, but accepting integral Decimal instances would parallel the current behaviour with floats:

>>> factorial(5.2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: factorial() only accepts integral values
>>> factorial(5.0)
120


Terry also observed:

>>> factorial(Fraction(5))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: an integer is required (got type Fraction)
History
Date User Action Args
2018-03-15 20:38:33mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, terry.reedy, facundobatista, skrah
2018-03-15 20:38:33mark.dickinsonsetmessageid: <1521146313.09.0.467229070634.issue33083@psf.upfronthosting.co.za>
2018-03-15 20:38:33mark.dickinsonlinkissue33083 messages
2018-03-15 20:38:32mark.dickinsoncreate