Main Menu
  • Welcome to The RPG Maker Resource Kit.

How to do Percents with decimals?

Started by shintashi, June 07, 2010, 11:11:34 AM

0 Members and 1 Guest are viewing this topic.

shintashi

How do I get something like this:

$game_variables[409] =
(($game_variables[408] * 11) /
$game_variables[410]) * 100


to work without the program totally screwing up the decimals?

for example, if var[408] is 10,

and var[410] is 120, I should get something that looks like 110/120 = 0.916...
that then gets converted into a percentage like 91.6%

obviously that's not what XP is doing, since it likes whole numbers.

modern algebra

Multiply it by 100 first then. You can also use floats.

$game_variables[408]*1100 / $game_variables[410]

shintashi

Quote from: modern algebra on June 07, 2010, 11:49:59 AM
Multiply it by 100 first then. You can also use floats.

$game_variables[408]*1100 / $game_variables[410]

I realized something like this about 5 am this morning but was too delirious to do anything about it (finals week). I was going to multiply everything by 10,000 first.

What's a floater?

I've heard of setting up variables A,B,C,D...for place holders.

cozziekuns

If you enter in:

$game_variables[xxxx] += 100, RPG Maker will automatically round to the nearest whole number. However, if you enter in $game_variables[xxxx] += 100.00, RPG Maker will automatically round to the nearest hundredth.

Basically, anything with a decimal point is a floating point number.

shintashi

Quote from: cozziekuns on June 07, 2010, 03:41:28 PM
If you enter in:

$game_variables[xxxx] += 100, RPG Maker will automatically round to the nearest whole number. However, if you enter in $game_variables[xxxx] += 100.00, RPG Maker will automatically round to the nearest hundredth.

Basically, anything with a decimal point is a floating point number.


do you think there's a way to set up Input number to have the option of decimals?

cozziekuns

Well, you could always just divide the variable by 100.00 (Zero's depend on how many places your willing to round of by) later.


tSwitch

what do you need exact decimals for, btw?


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon