Skip to main content

bool.tofloat()

Converts a bool to a float

Availability

Device + Agent

Returns

Float — 1.0 for true or 0.0 for false

Description

This method returns either 1.0 or 0.0 depending on whether the target bool is true or false.

Example Code

local anArray = [1, 2, 3, 4, 5, 6];
foreach (index, value in anArray) {
// Convert any even numbers to floats
local b = (value % 2 == 0);
if (b) anArray[index] = value * b.tofloat();
}
// anArray equals [1, 2.0, 3, 4.0, 5, 6.0]