Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: Noob on March 28, 2011, 06:15:40 pm

Title: A Very Simple Problem?
Post by: Noob on March 28, 2011, 06:15:40 pm
Hi, I'm in need of a script (most likely a single line of code to be used in an event) to allow me to multiply and divide variable and get decimal answers, or set a variable to a decimal value (This is in both RMVX and RMXP). But RPG Maker just seems to round it down whenever I try this...:/
So I need a line of code or a script modification that stops the rounding down, or bypasses it or something.
Thanks for your help!
Title: Re: A Very Simple Problem?
Post by: Aqua on March 28, 2011, 06:19:04 pm

$game_variables[ID] = 5 / 2.0


Result would be 2.5
Title: Re: A Very Simple Problem?
Post by: G_G on March 28, 2011, 07:37:38 pm
you must add a ".to_f" at the end of one of those numbers.
Title: Re: A Very Simple Problem?
Post by: Zeriab on March 29, 2011, 02:48:04 pm
Quote from: game_guy on March 28, 2011, 07:37:38 pm
you must add a ".to_f" at the end of one of those numbers.

It's not needed as 2.0 is a float. If anything it would be 5.to_f as 2.0.to_f is redundant, but the conversion happens automatically.
Not sure what happens if you try to multiply or divide a Bignum with a Float though-