Main Index : Reference :

float()


Description

Casts a variable to a float.

Definition

[float] float([int] x)

Parameters

x is a numeric value.

Return Value

float() returns x cast to a float.

Example

// Outputs "float(x) = 47.0000000".

var x = 47;
var a = float(x);

println("float(x) = ",a);


// Casting a variable to a float is needed if both
// variables in a division are integers.
//
// Outputs "int: 0  float: 0.571428571".

var x = 4;
var y = 7;

var a = x/y;
var b = float(x)/float(y);

println("int: ",a,"  float: ",b");

See Also

[float], int()