Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python division fuckup

Name: KILL YOURSELF 2009-12-10 16:34

Hey /prog,

I'm losing my mind over this. I have a bunch of integers and shit and I just want to get a new god damn variable and it keeps being zero and it's god damn annoying. What's wrong with my talentless "code"? (protip: Mitigation_Division_Comparison is the one that fucks up). I though I might be doing an integer divisor assclownery but checked with a // operator, and anyway this isn't supposed to be a problem in Python 3.x

Have at you

Attack_Power = 2800
Mitigation_Padding = 100
protectionvalue = 3000

Mitigation_Division_Comparison = (Attack_Power + Mitigation_Padding) / (protectionvalue + Mitigation_Padding)

Name: Anonymous 2009-12-10 16:36


Mitigation_Division_Comparison = (Attack_Power + Mitigation_Padding) * 1.0 / (protectionvalue + Mitigation_Padding)

Name: Anonymous 2009-12-10 16:42

the number you'd get is 0.00482758621. rounded to an integer, that's 0. if you're expecting an integer and not a floating point then your code is behaving as it should.

Name: Anonymous 2009-12-10 17:05

Mitigation_Division_Comparison = (float)(Attack_Power + Mitigation_Padding) / (float)(protectionvalue + Mitigation_Padding)

Also lol'd at variable names

Name: KILL YOURSELF 2009-12-10 17:14

Thanks a bunch, been driving me crazy. But thought Python 3 automagically corrected int/ int to float?

Name: Anonymous 2009-12-10 17:30

>>5
corrected
Are you sure you've selected the right hobby?

Name: Anonymous 2009-12-10 18:07

ADD ATTACK_POWER TO MITIGATION_PADDING GIVING MITIGATION_DIVISION_COMPARISON
ADD PROTECTIONVALUE TO MITIGATION_PADDING GIVING TEMPORARY
DIVIDE TEMPORARY INTO MITIGATION_DIVISION_COMPARISON

Name: Anonymous 2009-12-10 19:51

SUCK MY DICK GIVING HEAD

Name: Anonymous 2010-11-13 15:51

Name: Anonymous 2010-11-15 20:50

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List