Float

From ZCWiki
Jump to: navigation, search

The keyword float is used to define variables as floating point types (numbers with decimal places) and to indicate that functions return floating point values.

Examples

The first example demonstrates how to declare floating point variables.

float Temperature = 98.6;

The second example demonstrates how to declare a function that returns a floating point number.

float GetTemperature(){
  return 98.6;
}

Details

As far as ZScript is concerned, the float data type is for the most part the same as the int data type. Variables defined as float can store positive or negative values, and can be used in math operations with ints without having to convert data types (see typecasting).

See Also