The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: modern algebra on June 05, 2007, 06:12:15 AM

Title: [RESOLVED] Limiting decimal places in a float
Post by: modern algebra on June 05, 2007, 06:12:15 AM
Is there a way to limit the decimal places on a float?

I.e., if I have a float 6.6666666667, can I get rid of some of the decimals and make it just 6.67?
Title: Re: Limiting decimal places in a float
Post by: Zeriab on June 05, 2007, 10:16:35 PM
http://www.rubycentral.com/ref/ref_c_float.html
http://www.rubycentral.com/ref/ref_c_fixnum.html
http://www.rubycentral.com/ref/ref_c_bignum.html

float = 6.666666667
float = float * 100
float = float.round.to_f
float = float / 100
Title: Re: Limiting decimal places in a float
Post by: modern algebra on June 06, 2007, 12:09:54 AM
Thank you  ;D

I don't why I didn't think of that.