Hello,

Am Donnerstag, 2. April 2015 schrieb Steve Beattie:
> On Thu, Apr 02, 2015 at 09:55:24PM +0200, Christian Boltz wrote:
> > if 3/2 == 1:
> >     print("old python inside")
> 
> To be fair, it's doing integer math when both the numerator and
> denominator are integers; other things do this as well. Converting one
> of them to a float makes the division operation return a float as
> well:
> 
>   $ python2.7 -c 'print(3/2)'
>   1
>   $ python2.7 -c 'print(3.0/2)'
>   1.5

That makes it an even more interesting behaviour - one day earlier, and 
I'd have double-checked the result before believing you ;-)

For added fun:

# python2.7 -c 'print(float(3/2))'
1.0

;-)

(yes, I know it fails because it first does 3/2 and then converts the 
result to float - but it's still funny and (at least on the first view) 
misleading)


Regards,

Christian Boltz
-- 
Bei etwas größeren Dingen mit 6stelligem Budget kommt gern mal
"plötzlich" ein Onlineshop dazu. Oder ein Ticketsystem. So ganz
von alleine. Gucki, ich bin eine kleine Kundenidee - ist das viel
Arbeit? ;) [Ratti in suse-linux]


-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor

Reply via email to