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

Function ACoth

extern/ttmath/ttmath.h:1483–1516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1481 */
1482 template<class ValueType>
1483 ValueType ACoth(const ValueType & x, ErrorCode * err = 0)
1484 {
1485 if( x.IsNan() )
1486 {
1487 if( err )
1488 *err = err_improper_argument;
1489
1490 return x; // NaN
1491 }
1492
1493 ValueType nominator(x), denominator(x), one, result;
1494 uint c = 0;
1495 one.SetOne();
1496
1497 if( !x.GreaterWithoutSignThan(one) )
1498 {
1499 if( err )
1500 *err = err_improper_argument;
1501
1502 return result; // NaN is set by default
1503 }
1504
1505 c += nominator.Add(one);
1506 c += denominator.Sub(one);
1507 c += nominator.Div(denominator);
1508 c += result.Ln(nominator);
1509 c += result.exponent.SubOne();
1510
1511 // here can only be a carry
1512 if( err )
1513 *err = c ? err_overflow : err_ok;
1514
1515 return result;
1516 }
1517
1518
1519 /*!

Callers 1

ACtghFunction · 0.85

Calls 5

SetOneMethod · 0.80
AddMethod · 0.45
SubMethod · 0.45
DivMethod · 0.45
SubOneMethod · 0.45

Tested by

no test coverage detected