BLACKISH DEV BLOG Support
 

 

Unity: Converting int to float

a quick lesson learnt:

var num : float = 20 / 44; //result: 0

var num : float = parseFloat(20) / parseFloat(44); //result: 0.4545455
and just to be complete:
var num : float = 20.0 / 44.0; //result: 0.4545455
Bookmark the permalink. Follow any comments here with the RSS feed for this post. Trackbacks are closed, but you can post a comment.

One Comment

    Anonymous on February 16, 2011 at 13:42 | Permalink

    Great help, thanks!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>