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

Function Ceil

extern/ttmath/ttmath.h:139–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137 */
138 template<class ValueType>
139 ValueType Ceil(const ValueType & x, ErrorCode * err = 0)
140 {
141 if( x.IsNan() )
142 {
143 if( err )
144 *err = err_improper_argument;
145
146 return x; // NaN
147 }
148
149 ValueType result(x);
150 uint c = 0;
151
152 result.SkipFraction();
153
154 if( result != x )
155 {
156 // x is with fraction
157 // if x is negative we don't have to do anything
158 if( !x.IsSign() )
159 {
160 ValueType one;
161 one.SetOne();
162
163 c += result.Add(one);
164 }
165 }
166
167 if( err )
168 *err = c ? err_overflow : err_ok;
169
170 return result;
171 }
172
173
174 /*!

Callers

nothing calls this directly

Calls 3

IsSignMethod · 0.80
SetOneMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected