MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / Coth

Function Coth

extern/ttmath/ttmath.h:1280–1315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1278 */
1279 template<class ValueType>
1280 ValueType Coth(const ValueType & x, ErrorCode * err = 0)
1281 {
1282 if( x.IsNan() )
1283 {
1284 if( err )
1285 *err = err_improper_argument;
1286
1287 return x; // NaN
1288 }
1289
1290 if( x.IsZero() )
1291 {
1292 if( err )
1293 *err = err_improper_argument;
1294
1295 return ValueType(); // NaN is set by default
1296 }
1297
1298 ValueType ex, emx, nominator, denominator;
1299 uint c = 0;
1300
1301 c += ex.Exp(x);
1302 c += emx.Exp(-x);
1303
1304 nominator = ex;
1305 c += nominator.Add(emx);
1306 denominator = ex;
1307 c += denominator.Sub(emx);
1308
1309 c += nominator.Div(denominator);
1310
1311 if( err )
1312 *err = c ? err_overflow : err_ok;
1313
1314 return nominator;
1315 }
1316
1317
1318 /*!

Callers 1

CtghFunction · 0.85

Calls 5

ValueTypeEnum · 0.85
IsZeroMethod · 0.80
AddMethod · 0.45
SubMethod · 0.45
DivMethod · 0.45

Tested by

no test coverage detected