Jump to content

automatic number type conversion


photo

Recommended Posts

This is an expected behaviour because rand() returns float.

 

Please refer to the documentation (Programming / UnigineScript Language / Data Types):

 

UnigineScript uses dynamic typing; this is different from C++ where static typing is used. This means that type checking will be performed only during execution. There are several important consequences from this fact:

 

* Though in many parts of documentation you can see variables declared with specific types or function arguments of specific types, these type markers are simply hints to the user. That is, you can define an int variable and assign a string to it.

* The interpreter will not do type checking for you before it starts evaluating an expression. If you need data of a specific type or a specific custom class, use the typeof() and typeinfo() functions to check it.

* From time to time you will see a variable type in function declarations. variable is not actually a type, and this word is not even reserved. The variable pseudo-type simply means that a function "knows" that it can accept data of different types and will act differently depending on the type of the variable argument.

* Still, there are several base types, which names are reserved, and we will briefly examine them here. Also, you can define your own types—classes.

Link to comment
×
×
  • Create New...