Float bug i think.

Bugs will be moved here once resolved.

Post » Fri Oct 14, 2011 12:21 am

Ok i have a event every 1 seconds add 0.1 to global variable Speed,
And have every tick set text "Speed: "&Speed but it keeps disapearing and sometimes reapears, it always dissapears at 0.2 and reapears at 0.4 then dissapears again.
if i set "Speed: "&floor(Speed) it stays there displayed but obviously is rounded to an int so it only updates on whole numbers. And if i put "Speed: "&float(Speed) it still dissapears..
B
40
S
14
G
11
Posts: 243
Reputation: 9,432

Post » Fri Oct 14, 2011 12:35 am

The text object doesn't display text if it's not big enough. Are you sure you resized your text object big enough? If so, can you post a .capx?
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,564

Post » Fri Oct 14, 2011 12:56 am

ok here you go

http://www.mediafire.com/?crraqcbpo788c9r

just incase another link.

http://dl.dropbox.com/u/44766364/RollerBallB1.capxtonycrew2011-10-14 01:06:00
B
40
S
14
G
11
Posts: 243
Reputation: 9,432

Post » Fri Oct 14, 2011 9:21 am

You can see from the picture below, the value the text field needs to show is very long.



As you are only incrementing by 0.1 at a time, I would say this is not what you would expect to happen. FormatDecimal from CC would be useful here.

Ashley will be able to say whether this is expected behavior or a bug.zenox982011-10-14 09:35:55
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,844
Reputation: 48,289

Post » Fri Oct 14, 2011 1:05 pm

Like I thought, the text object isn't big enough to display the actual number "3.6000000000002" as zenox showed.

Computers cannot do fractional calculations with infinite precision, because that would require infinite computing power, so there are always small errors. Try setting the text object to:

round(Speed * 10) / 10

to only display one decimal place. In the next build I'll add some degree of rounding in the text object itself so this doesn't happen.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,564

Post » Fri Oct 14, 2011 5:26 pm

Thanks that works great :)tonycrew2011-10-14 17:29:39
B
40
S
14
G
11
Posts: 243
Reputation: 9,432

Post » Fri Oct 14, 2011 6:46 pm

[QUOTE=Ashley]In the next build I'll add some degree of rounding in the text object itself so this doesn't happen.[/QUOTE]

On one hand, I like that idea, but on the other, then the text object won't show the actual value and I'm concerned that could potentially be really frusterating when debugging.

Maybe a property could be added to turn that on/off?
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,422

Post » Fri Oct 14, 2011 8:45 pm

I think it's a good default, since you shouldn't rely on exact float comparisons anyway. However, the system str expression won't do any rounding, so if you want to see the un-rounded value you can do str(value).
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,564

Post » Fri Oct 14, 2011 8:51 pm

Ah, ok. Happy there's a work around, then.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,422

Post » Sat Oct 15, 2011 12:15 am

Or whay about adding to what decimal point we want rounded... 10ths/100ths/1000ths/ just an idea..
B
40
S
14
G
11
Posts: 243
Reputation: 9,432

Next

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 3 guests