|
Jacob Shaftoe
Registered User
Join date: 20 Apr 2005
Posts: 22
|
09-03-2006 18:17
Can someone please explain why these examples are not working (just assume they are in state_entry()
float this = 0.5; float that = 0.4; llSay(0, this - that); // Shouldn't that return 0.1?
That's just one example... Is there something I'm missing?
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
Maybe
09-03-2006 18:25
Numbers are represented in binary. The problem is that 0.1 can't be precisely repp'ed in binary, so you get something like 0.099999 or .010000001 or whatever.
If it is really close, you are fine. Look out for ==. it is possible that 0.5-0.4 might not == =.1.
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
09-03-2006 18:26
From: Jacob Shaftoe Is there something I'm missing? llSay() expects argument of type 'string'. You are feeding it with a float. So it complains about wrong parameter format. You can fix it by explicitly casting result of math operation into expected argument type: llSay( 0, (string)(this - that) );
|
|
Jacob Shaftoe
Registered User
Join date: 20 Apr 2005
Posts: 22
|
09-03-2006 18:31
From: Joannah Cramer llSay() expects argument of type 'string'. You are feeding it with a float. So it complains about wrong parameter format.
You can fix it by explicitly casting result of math operation into expected argument type:
llSay( 0, (string)(this - that) ); Oh awesome, I just figured that out right before you wrote that. Sweet. Thanks man!
|