xigaro Posted October 20, 2012 Share Posted October 20, 2012 If I put this in a script... default{ state_entry() { float example = 1/11; llSay(0, (string)example); }} ....it returns "0.000000"Why's that then? Link to comment Share on other sites More sharing options...
Dora Gustafson Posted October 20, 2012 Share Posted October 20, 2012 1 and 11 are integers and 1/11 becomes 0 Try 1.0/11.0 instead. Link to comment Share on other sites More sharing options...
xigaro Posted October 20, 2012 Author Share Posted October 20, 2012 Thank you! I come from a world of lazy scripting languages, types aren't familiar to me It makes sense now! Link to comment Share on other sites More sharing options...
Rolig Loon Posted October 20, 2012 Share Posted October 20, 2012 Because even though you have declared your variable example to be a float, the numbers 1 and 11 are not. They are integers. If you divide an integer by an integer, the result is an integer rounded down to the nearest integer. In this case, 1/11 = 0 . If you want a realistic float result, write float example = 1.0/11.0; 1.0/11.0 = 0.090909090909 Edit: Hah! Dora is faster today. :smileylol: Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now