MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / my_decimal2binary

Function my_decimal2binary

sql/my_decimal.cc:196–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194*/
195
196int my_decimal2binary(uint mask, const my_decimal *d, uchar *bin, int prec,
197 int scale)
198{
199 int err1= E_DEC_OK, err2;
200 my_decimal rounded;
201 my_decimal2decimal(d, &rounded);
202 rounded.frac= decimal_actual_fraction(&rounded);
203 if (scale < rounded.frac)
204 {
205 err1= E_DEC_TRUNCATED;
206 /* decimal_round can return only E_DEC_TRUNCATED */
207 decimal_round(&rounded, &rounded, scale, HALF_UP);
208 }
209 err2= decimal2bin(&rounded, bin, prec, scale);
210 if (!err2)
211 err2= err1;
212 return check_result(mask, err2);
213}
214
215
216/*

Callers

nothing calls this directly

Calls 5

my_decimal2decimalFunction · 0.85
decimal_actual_fractionFunction · 0.85
decimal_roundFunction · 0.85
decimal2binFunction · 0.85
check_resultFunction · 0.85

Tested by

no test coverage detected