[NumPy-Tickets] [NumPy] #1690: numpy.random.randint(-2147483648, 2147483647) raises ValueError: low >= high

NumPy Trac numpy-tickets@scipy....
Tue Jan 4 02:25:48 CST 2011


#1690: numpy.random.randint(-2147483648, 2147483647) raises ValueError: low >=
high
--------------------------+-------------------------------------------------
 Reporter:  tkf           |       Owner:  somebody    
     Type:  defect        |      Status:  needs_review
 Priority:  normal        |   Milestone:  2.0.0       
Component:  numpy.random  |     Version:  1.5.0       
 Keywords:                |  
--------------------------+-------------------------------------------------
Changes (by jpeel):

  * status:  new => needs_review


Comment:

 It is clearly an overflow problem. I fixed the problem by:

 1. checking explicitly if lo >= hi before raising the ValueError given
 above.

 2. changing diff to an unsigned long, typecasting hi and lo to long longs
 before subtracting them, then typecasting the result to an unsigned long
 to be put in diff.

 Everything is working quite well with these changes.

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1690#comment:2>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list