MCPcopy Create free account
hub / github.com/defold/defold / safe_div

Function safe_div

engine/dlib/src/basis/encoder/cppspmd_math.h:36–39  ·  view source on GitHub ↗

Avoids dividing by zero or very small values.

Source from the content-addressed store, hash-verified

34
35// Avoids dividing by zero or very small values.
36CPPSPMD_FORCE_INLINE vfloat safe_div(vfloat a, vfloat b, float fDivThresh = 1e-7f)
37{
38 return a / spmd_ternaryf( abs(b) > fDivThresh, b, spmd_ternaryf(b < 0.0f, -fDivThresh, fDivThresh) );
39}
40
41/*
42 clang 9.0.0 for win /fp:precise release

Callers

nothing calls this directly

Calls 2

spmd_ternaryfFunction · 0.85
absFunction · 0.85

Tested by

no test coverage detected