Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[Resolved] Variable Problem (a/b != working?)

Hi ho~

I have a variable problem.

a = 48
b = 91
c = (a/b)
p c
Prints returns 0?
So I'm thinking, maybe it can't do numbers between 0 and 1. Then I do:
c = ((a/b)*100)
p c
Still 0.

The heck? o_O
 
48 / 91 gives 0.527, a float. RMXP will automatically round this number to the lowest integer unless the given numbers are floats too.

Try 48.0 / 91.0 and it should return 0.527.
A good thing to know if you work with variables, like num1 = 12, num2 = 38.4, etc. is that you can turn numerics to integer or float by using the 'to_i' and 'to_f' methods.

So num1.to_f = 12.0
and num2.to_i = 38

Hope it helps!
-Dargor
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top