playMaker

Author Topic: Deduct Percentage?  (Read 2856 times)

derkoi

  • Full Member
  • ***
  • Posts: 187
Deduct Percentage?
« on: May 21, 2013, 05:48:24 AM »
Hi, I'm trying to deduct a percentage from a float value. Any idea how I can do that please?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Deduct Percentage?
« Reply #1 on: May 21, 2013, 05:56:28 AM »
Hi,

first solution:

You need to get the percentage itself of that value, then you substract that to the  value itself.

value = 35
percentage to substract: 5%
5% of 35 is (35*0.05) = 1.75
the new value is (35-1.75) = 33.25

OR

you get the opposite percent ( what you want to keep)
you want to get 95% of the value ( 100%-5%), 1-0,5 = 0.95
the new value is (35*0.95) = 33.25

 if your percent comes as "95" then you simply divide by "100"

35*95/100 = 33.25

Does that help?

bye,

 Jean

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Deduct Percentage?
« Reply #2 on: May 21, 2013, 07:39:44 AM »
Multiplying by "0.nn" will work fine.

As long as it is a number less than the smallest positive whole then it will work as a percentage so you can just multiply by 0.9 to get 90% of something. If you're working differently in the background I would suggest multiplying the number to display it to the player as you want and keeping the "0.nn" number in the background calcs for simplicity.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D