Documentation

Unity Engine

Download Unity

Unity Engine

sqrtsafe

Returns the square root of a float value, or zero if the value isn't greater than zero.
Read time 3 minutesLast updated 5 days ago

Definition

sqrtsafe(float)

Returns the square root of a float value, or zero if the value isn't greater than zero.
public static float sqrtsafe(float x)

Parameters

Value to use when computing square root.

Returns

Type

Description

floatThe square root of the input, or zero.

Remarks

Unlike math.sqrt, negative and NaN inputs return zero instead of NaN.

sqrtsafe(float2)

Returns the componentwise square root of a float2 vector, or zero for each component that isn't greater than zero.
public static float2 sqrtsafe(float2 x)

Parameters

Value to use when computing square root.

Returns

Type

Description

float2The componentwise square root of the input, or zero.

Remarks

Unlike math.sqrt, negative and NaN components return zero instead of NaN.

sqrtsafe(float3)

Returns the componentwise square root of a float3 vector, or zero for each component that isn't greater than zero.
public static float3 sqrtsafe(float3 x)

Parameters

Value to use when computing square root.

Returns

Type

Description

float3The componentwise square root of the input, or zero.

Remarks

Unlike math.sqrt, negative and NaN components return zero instead of NaN.

sqrtsafe(float4)

Returns the componentwise square root of a float4 vector, or zero for each component that isn't greater than zero.
public static float4 sqrtsafe(float4 x)

Parameters

Value to use when computing square root.

Returns

Type

Description

float4The componentwise square root of the input, or zero.

Remarks

Unlike math.sqrt, negative and NaN components return zero instead of NaN.

sqrtsafe(double)

Returns the square root of a double value, or zero if the value isn't greater than zero.
public static double sqrtsafe(double x)

Parameters

Value to use when computing square root.

Returns

Type

Description

doubleThe square root of the input, or zero.

Remarks

Unlike math.sqrt, negative and NaN inputs return zero instead of NaN.

sqrtsafe(double2)

Returns the componentwise square root of a double2 vector, or zero for each component that isn't greater than zero.
public static double2 sqrtsafe(double2 x)

Parameters

Value to use when computing square root.

Returns

Type

Description

double2The componentwise square root of the input, or zero.

Remarks

Unlike math.sqrt, negative and NaN components return zero instead of NaN.

sqrtsafe(double3)

Returns the componentwise square root of a double3 vector, or zero for each component that isn't greater than zero.
public static double3 sqrtsafe(double3 x)

Parameters

Value to use when computing square root.

Returns

Type

Description

double3The componentwise square root of the input, or zero.

Remarks

Unlike math.sqrt, negative and NaN components return zero instead of NaN.

sqrtsafe(double4)

Returns the componentwise square root of a double4 vector, or zero for each component that isn't greater than zero.
public static double4 sqrtsafe(double4 x)

Parameters

Value to use when computing square root.

Returns

Type

Description

double4The componentwise square root of the input, or zero.

Remarks

Unlike math.sqrt, negative and NaN components return zero instead of NaN.