1/2 evaluates to 0

Aage Andersen (REMOVE) aaan at email.dk
Wed Oct 12 06:27:03 EDT 2011


"Laurent Claessens" <moky.math at gmail.com> skrev i en meddelelse 
news:j73p9s$baa$1 at news.univ-fcomte.fr...
> Hi all
>
>
> This is well known :
>
> >>> 1/2
> 0
>
> This is because the division is an "integer division".
>
> My question is : how can I evaluate 1/2 to 0.5 ? Is there some non integer 
> division operator ?
> Up to now I workarounded writing float(1)/2. Is there an other way ?

what about 1.0/2 ? 





More information about the Python-list mailing list