pong wrote:
> Thanks for the suggestion. I understand it now.
>
> Just curious, so what exactly does SAGE do when I type 0.6**2 then?
> I tried a quick search with SAGE tutorial this time, but didn't seem
> to find what I'm looking for.
>
Sage "preparses" the input and transforms it like this:
sage: preparse('0.6**2')
"RealNumber('0.6')**Integer(2)"
So what is *actually* run is:
RealNumber('0.6')**Integer(2)
These are Sage-specific things, so you wouldn't be able to just type the
above into python and expect it to work without importing and using Sage.
Jason
> Thanks in advance
>
> On Nov 14, 10:06 am, William Stein <[email protected]> wrote:
>> On Sat, Nov 14, 2009 at 9:17 AM, pong <[email protected]> wrote:
>>
>>> I apologize in advance that this is essentially a question about
>>> python instead of sage.
>>> When I type 0.6**2 in python, it returns
>>> 0.35999999999999999
>>> When I do the same in SAGE
>>> 0.360000000000000
>>> It gives the correct answer. Why so? And can I make python gives the
>>> "correct" answer as well?
>> I highly recommend that you read
>>
>> http://docs.python.org/tutorial/floatingpoint.html
>>
>> to understand why Python does what it does.
>>
>> William
> >
>
--
Jason Grout
--~--~---------~--~----~------------~-------~--~----~
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-support
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---