#4250 NORM Future : Calculate should use exact numbers when possible and displaying number should be more friendly.

Zarro Boogs per Child bugtracker at laptop.org
Sun Nov 18 07:29:15 EST 2007


#4250: Calculate should use exact numbers when possible and displaying number
should be more friendly.
----------------------------------+-----------------------------------------
  Reporter:  ohshima              |       Owner:  rwh           
      Type:  defect               |      Status:  new           
  Priority:  normal               |   Milestone:  Future Release
 Component:  calculator-activity  |     Version:                
Resolution:                       |    Keywords:                
  Verified:  0                    |  
----------------------------------+-----------------------------------------

Comment(by bert):

 Replying to [comment:3 rwh]:
 > Now the factorial function is really not that complicated (implemented
 recursively).

 But Python limits stack depth so recursion isn't an option.

 Replying to [comment:8 rwh]:
 > Note that integer operations are indeed accurate, but not in the case of
 evaluation 2000!/1999! because 2000! is a 5735 digit number...

 {{{
 >>> def factorial(n):
 ...    product = 1
 ...    for i in range(2, n):
 ...       product = product * i
 ...    return product
 ...
 >>> factorial(2000)/factorial(1999)
 2000L
 }}}

 So why shouldn't it be possible to do exact integer arithmetics? Python
 can handle that fine.

 Calculate should also handle rational numbers accurately, I bet there is a
 module for Python allowing that. If not, it can hardly be more than a page
 of code.

-- 
Ticket URL: <http://dev.laptop.org/ticket/4250#comment:9>
One Laptop Per Child <http://dev.laptop.org>
OLPC bug tracking system



More information about the Bugs mailing list