| 194 | */ |
| 195 | |
| 196 | int 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 | /* |
nothing calls this directly
no test coverage detected