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: 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.)



> in sage:
>
> sage: 2^3
> 8
>
> in python
>   
>>>> 2^3
>>>>         
> 1
>   

In Sage, for mathematical convenience and consistency, "^" means 
exponentiation, while in Python "^" means XOR (and "**" means 
exponentiation).  In Sage 3.1.2, "^^" is XOR (see trac ticket #2569).

Thanks,

Jason




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to