Variables with decimals?

For questions about using Classic.

Post » Tue Jul 24, 2012 11:18 am

I have an ini file with only one object, "version". At this moment, it is 2.40 but that's subject to change.

However, when I assign that same object to a global variable (tried setting it to both number and text), it goes down to 2. At least that's what the text box I placed says.

It is really important that it stays at 2.40 (including the 0).

Thanks in advance.
B
4
S
1
G
2
Posts: 75
Reputation: 1,000

Post » Tue Jul 24, 2012 12:11 pm

Use the str() expression to save it as a string.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Fri Jul 27, 2012 6:27 am

If you need a specific number of decimals, you better use FormatDecimal(number, N), because str() will convert 2.40 to "2.4", omitting the last 0

With FormatDecimal(2.4, 2) you will get a string with 2 digits for the decimals "2.40"
Likewise, FormatDecimal(2.41, 3) will return "2.410", etc.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests