Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

Typecasting


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 meink   Members   -  Reputation: 133

Like
Likes
Like

Posted 25 May 2004 - 04:52 PM

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

Sponsor:

#2 Desdemona   Members   -  Reputation: 158

Like
Likes
Like

Posted 25 May 2004 - 05:41 PM

Type casting can be done like this:

floatfunc(float(l) * 0.2f);


#3 Andreas Jonsson   Moderators   -  Reputation: 3352

Like
Likes
Like

Posted 26 May 2004 - 01:05 PM

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]

#4 meink   Members   -  Reputation: 133

Like
Likes
Like

Posted 26 May 2004 - 06:29 PM

OK, thanks for your help

- Xavier




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS