Documentation

Unity Engine

Download Unity

Unity Engine

log2safe

Returns the base-2 logarithm of a float value, or zero if the value isn't greater than epsilon.
Read time 4 minutesLast updated 5 days ago

Definition

log2safe(float, float)

Returns the base-2 logarithm of a float value, or zero if the value isn't greater than epsilon.
public static float log2safe(float x, float epsilon = 1.1754944E-38)

Parameters

Input value.

epsilon

Threshold value. Defaults to math.FLT_MIN_NORMAL.

Returns

Type

Description

floatThe base-2 logarithm of the input, or zero.

Remarks

Unlike math.log2, inputs that aren't greater than epsilon, including zero, negative values and NaN, return zero instead of negative infinity or NaN.

log2safe(float2, float)

Returns the componentwise base-2 logarithm of a float2 vector, or zero for each component that isn't greater than epsilon.
public static float2 log2safe(float2 x, float epsilon = 1.1754944E-38)

Parameters

Input value.

epsilon

Threshold value. Defaults to math.FLT_MIN_NORMAL.

Returns

Type

Description

float2The componentwise base-2 logarithm of the input, or zero.

Remarks

Unlike math.log2, components that aren't greater than epsilon, including zero, negative values and NaN, return zero instead of negative infinity or NaN.

log2safe(float3, float)

Returns the componentwise base-2 logarithm of a float3 vector, or zero for each component that isn't greater than epsilon.
public static float3 log2safe(float3 x, float epsilon = 1.1754944E-38)

Parameters

Input value.

epsilon

Threshold value. Defaults to math.FLT_MIN_NORMAL.

Returns

Type

Description

float3The componentwise base-2 logarithm of the input, or zero.

Remarks

Unlike math.log2, components that aren't greater than epsilon, including zero, negative values and NaN, return zero instead of negative infinity or NaN.

log2safe(float4, float)

Returns the componentwise base-2 logarithm of a float4 vector, or zero for each component that isn't greater than epsilon.
public static float4 log2safe(float4 x, float epsilon = 1.1754944E-38)

Parameters

Input value.

epsilon

Threshold value. Defaults to math.FLT_MIN_NORMAL.

Returns

Type

Description

float4The componentwise base-2 logarithm of the input, or zero.

Remarks

Unlike math.log2, components that aren't greater than epsilon, including zero, negative values and NaN, return zero instead of negative infinity or NaN.

log2safe(double, double)

Returns the base-2 logarithm of a double value, or zero if the value isn't greater than epsilon.
public static double log2safe(double x, double epsilon = 2.2250738585072014E-308)

Parameters

Input value.

epsilon

Threshold value. Defaults to math.DBL_MIN_NORMAL.

Returns

Type

Description

doubleThe base-2 logarithm of the input, or zero.

Remarks

Unlike math.log2, inputs that aren't greater than epsilon, including zero, negative values and NaN, return zero instead of negative infinity or NaN.

log2safe(double2, double)

Returns the componentwise base-2 logarithm of a double2 vector, or zero for each component that isn't greater than epsilon.
public static double2 log2safe(double2 x, double epsilon = 2.2250738585072014E-308)

Parameters

Input value.

epsilon

Threshold value. Defaults to math.DBL_MIN_NORMAL.

Returns

Type

Description

double2The componentwise base-2 logarithm of the input, or zero.

Remarks

Unlike math.log2, components that aren't greater than epsilon, including zero, negative values and NaN, return zero instead of negative infinity or NaN.

log2safe(double3, double)

Returns the componentwise base-2 logarithm of a double3 vector, or zero for each component that isn't greater than epsilon.
public static double3 log2safe(double3 x, double epsilon = 2.2250738585072014E-308)

Parameters

Input value.

epsilon

Threshold value. Defaults to math.DBL_MIN_NORMAL.

Returns

Type

Description

double3The componentwise base-2 logarithm of the input, or zero.

Remarks

Unlike math.log2, components that aren't greater than epsilon, including zero, negative values and NaN, return zero instead of negative infinity or NaN.

log2safe(double4, double)

Returns the componentwise base-2 logarithm of a double4 vector, or zero for each component that isn't greater than epsilon.
public static double4 log2safe(double4 x, double epsilon = 2.2250738585072014E-308)

Parameters

Input value.

epsilon

Threshold value. Defaults to math.DBL_MIN_NORMAL.

Returns

Type

Description

double4The componentwise base-2 logarithm of the input, or zero.

Remarks

Unlike math.log2, components that aren't greater than epsilon, including zero, negative values and NaN, return zero instead of negative infinity or NaN.