how to format small decimals without the E scientific notati

For questions about using Classic.

Post » Wed Mar 02, 2011 10:41 pm

numbers smaller than 0.1 format very ugly
is there a way to format something so it just shows up how you'd expect it to?
like:
formatdecimal(2,0.01235)
I just want it to say
0.01
but instead it formats to
e+000
http://dl.dropbox.com/u/1013446/seriously.cap
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Wed Mar 02, 2011 11:09 pm

If there's a way to put a number into a string, then you can just print that instead, right? And if you also want to format it, then you can multiply by 100, use the floor() function, and then divide by 100 and put that in the string.

(If you managed to catch my previous post before I deleted it, yeah, that doesn't work at all. :P My bad!)
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Wed Mar 02, 2011 11:10 pm

Here's one way:

int(0.01)&"."&ZeroPad(int(100*0.01),2)
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Thu Mar 03, 2011 12:51 am

oh thanks guys, just came back here, my solution was much uglier:
assuming your decimal number was x:


((x<0.1)?("0."&right(formatdecimal(1+x,3),2)):formatdecimal(x,3))
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests