• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Unexpected variable rounding (SOLVED)

S

ShaunBartoo

Guest
Hi,

Please excuse me if I'm missing something obvious. I'm pretty new to GML and not an expert at programming in general.

I've noticed that my variables are automatically rounding to 2 decimal places for some reason. For example,

Code:
var test = 0.075;
show_debug_message("test: " + string(test));
I get the following output:

Code:
test: 0.07
Can someone clarify for me why my variables are automatically rounding?

Thank you for reading!

EDIT: Figured it out.The rounding issue was being caused by the conversion from real to string. I resolved this by changing the debug_message to

Code:
show_debug_message("test: " + string_format(test, string_length(string(round(test))), 3));
 
Last edited by a moderator:
Top