From ZCWiki
Jump to navigationJump to 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.

NOTE: "float" does not actually use an integer type, but rather a fixed-point type.


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;


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