Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Simple math... or is it?

Author
Message
Deego
16
Years of Service
User Offline
Joined: 21st May 2008
Location:
Posted: 12th Aug 2008 05:42
I'm trying to create an accuracy value. If a player misses the target, their total value increases by 1, and if they hit the target, their total and hit values increase by 1. To get the accuracy, it's basic math, right? I can't get any acc from this:


Ideally, this would give acc a value between 0 and 100. But acc only returns 0 if total > hit and 100 if total < hit. Why won't a hit value of 8 and a total value of 10 make acc = 80?
HexM
16
Years of Service
User Offline
Joined: 29th Jul 2008
Location:
Posted: 12th Aug 2008 06:07
I believe it does the multiplication before the division. So you should put (hit/total) * 100.
Deego
16
Years of Service
User Offline
Joined: 21st May 2008
Location:
Posted: 12th Aug 2008 10:50
It's the same with the parenthesis as without.
HexM
16
Years of Service
User Offline
Joined: 29th Jul 2008
Location:
Posted: 12th Aug 2008 12:04
Ok, i think you just need to set them all as floats. because they are integers. then just round off acc using int() to get an even percentage.
Deego
16
Years of Service
User Offline
Joined: 21st May 2008
Location:
Posted: 12th Aug 2008 20:27
It works, but only after I removed the initial declaration of variables.



Thanks!

Login to post a reply

Server time is: 2024-11-24 23:11:48
Your offset time is: 2024-11-24 23:11:48