Typecasting

Started by
2 comments, last by meink 19 years, 11 months ago

void floatfunc(float);
int l = 1;

floatfunc(l * 0.2);
 
The parameter in the function call is evaluated as an integer, not a float. Shouldn''t it be the other way around? On that note, is there anyway to typecast in angelscript? As a workaround I''m using my own toInt and toFloat functions that I expose to AS. - Xavier
Advertisement
Type casting can be done like this:

floatfunc(float(l) * 0.2f);
The scripting language doesn't do any implicit casting of variable types. Which is why the value is evaluated as integer.

That said, I think the correct way would be to have the compiler give a warning that the float is implicitly cast to integer. Or perhaps even an error. I might change this for future versions of AngelScript.



__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library - Tower - free puzzle game

[edited by - WitchLord on May 27, 2004 6:54:25 AM]

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

OK, thanks for your help

- Xavier

This topic is closed to new replies.

Advertisement