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

Function RootCheckIndex

extern/ttmath/ttmath.h:1990–2019  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1988
1989 template<class ValueType>
1990 bool RootCheckIndex(ValueType & x, const ValueType & index, ErrorCode * err, bool * change_sign)
1991 {
1992 *change_sign = false;
1993
1994 if( index.Mod2() )
1995 {
1996 // index is odd (1,3,5...)
1997 if( x.IsSign() )
1998 {
1999 *change_sign = true;
2000 x.Abs();
2001 }
2002 }
2003 else
2004 {
2005 // index is even
2006 // x cannot be negative
2007 if( x.IsSign() )
2008 {
2009 if( err )
2010 *err = err_improper_argument;
2011
2012 x.SetNan();
2013
2014 return true;
2015 }
2016 }
2017
2018 return false;
2019 }
2020
2021
2022 template<class ValueType>

Callers 1

RootFunction · 0.85

Calls 2

IsSignMethod · 0.80
AbsMethod · 0.80

Tested by

no test coverage detected