On Sep 16, 2008, at 1:25 PM, [EMAIL PROTECTED] wrote: > William Stein wrote: >> On Tue, Sep 16, 2008 at 1:10 PM, Jose <[EMAIL PROTECTED]> wrote: >> >>> Sorry for the confusion regarding range(). >>> >>> Are there other idioms not in standard python that should be >>> highlighted? >>> >>> Thanks! >>> >> >> > > I'll take a shot at brief explanations for the archive's sake. > > >> sage: 1/3 >> 1/3 # instead of 0 >> >> > > Sage makes rational numbers, while Python does integer division. > > >> sage: 1/3.0 >> 0.333333333333333 >> >> but in Python: >> >>>>> 1/3.0 >>>>> >> 0.33333333333333331 >> >> > > Sage uses more precise arithmetic?
Sage avoid showing the last couple of bits to hide numerical noise. It also uses MPFR by default. > > >> >> sage: 1.290283409823049820938409283409823408234 >> 1.290283409823049820938409283409823408234 >> >> but in python >> >> >>>>> 1.290283409823049820938409283409823408234 >>>>> >> 1.2902834098230498 >> > > Sage uses arbitrary precision floats by default, while Python only > uses > double precision. (Is it really arbitrary precision? I think it is.) Sage uses fixed precision floating point numbers, with the precision determined by the number of digits in the input. - Robert --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sage-edu" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-edu?hl=en -~----------~----~----~----~------~----~------~--~---
