summaryrefslogtreecommitdiff
path: root/sql/my_decimal.cc
diff options
context:
space:
mode:
authorunknown <holyfoot@hf-ibm.(none)>2005-05-05 20:06:49 +0500
committerunknown <holyfoot@hf-ibm.(none)>2005-05-05 20:06:49 +0500
commit6de14a23f7de447e4e6c4b82e2be032b05214c9a (patch)
tree28239d480c5b5f518077513738c6718aafd3584d /sql/my_decimal.cc
parentc0f355762547c01192478b60659038b7751a1ced (diff)
downloadmariadb-git-6de14a23f7de447e4e6c4b82e2be032b05214c9a.tar.gz
A lot of fixes to Precision math
Mostly about precision/decimals of the results of the operations include/decimal.h: decimal interface changed a little sql/field.cc: a lot of precision/decimals related changes to the Field_new_decimal sql/field.h: Field_new_decimal interface changed sql/ha_ndbcluster.cc: f->precision should be used here sql/item.cc: precision/decimals counting related changes sql/item.h: precision/decimals counting related changes sql/item_cmpfunc.cc: precision/decimals counting related changes sql/item_cmpfunc.h: precision/decimals counting related changes sql/item_func.cc: precision/decimals counting related changes sql/item_func.h: precision/decimals counting related changes sql/item_sum.cc: precision/decimals counting related changes sql/item_sum.h: precision/decimals counting related changes sql/my_decimal.cc: precision/decimals counting related changes sql/my_decimal.h: precision/decimals counting related changes sql/mysqld.cc: precision/decimals counting related changes sql/set_var.cc: precision/decimals counting related changes sql/sp_head.cc: dbug_decimal_print was replaced with dbug_decimal_as_string sql/sql_class.h: div_precincrement variable added sql/sql_parse.cc: precision/decimals counting related changes sql/sql_select.cc: precision/decimals counting related changes sql/sql_show.cc: Field::representation_length was removed strings/decimal.c: decimal_actual_fraction was introduced BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'sql/my_decimal.cc')
-rw-r--r--sql/my_decimal.cc20
1 files changed, 9 insertions, 11 deletions
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc
index b4bbef4a637..14c15cdc4ef 100644
--- a/sql/my_decimal.cc
+++ b/sql/my_decimal.cc
@@ -81,7 +81,7 @@ int decimal_operation_results(int result)
*/
int my_decimal2string(uint mask, const my_decimal *d,
- int fixed_prec, int fixed_dec,
+ uint fixed_prec, uint fixed_dec,
char filler, String *str)
{
int length= (fixed_prec ? (fixed_prec + 1) : my_decimal_string_length(d));
@@ -89,7 +89,7 @@ int my_decimal2string(uint mask, const my_decimal *d,
if (str->alloc(length))
return check_result(mask, E_DEC_OOM);
result= decimal2string((decimal_t*) d, (char*) str->ptr(),
- &length, fixed_prec, fixed_dec,
+ &length, (int)fixed_prec, fixed_dec,
filler);
str->length(length);
return check_result(mask, result);
@@ -123,7 +123,7 @@ int my_decimal2binary(uint mask, const my_decimal *d, char *bin, int prec,
int err1= E_DEC_OK, err2;
my_decimal rounded;
my_decimal2decimal(d, &rounded);
- decimal_optimize_fraction(&rounded);
+ rounded.frac= decimal_actual_fraction(&rounded);
if (scale < rounded.frac)
{
err1= E_DEC_TRUNCATED;
@@ -220,18 +220,16 @@ print_decimal_buff(const my_decimal *dec, const byte* ptr, int length)
}
-void dbug_print_decimal(const char *tag, const char *format, my_decimal *val)
+const char *dbug_decimal_as_string(char *buff, const my_decimal *val)
{
- char buff[DECIMAL_MAX_STR_LENGTH];
- String str(buff, sizeof(buff), &my_charset_bin);
+ int length= DECIMAL_MAX_STR_LENGTH;
if (!val)
- str.set("NULL", 4, &my_charset_bin);
- else
- my_decimal2string(0, val, 0, 0, 0, &str);
- DBUG_PRINT(tag, (format, (char*) str.ptr()));
+ return "NULL";
+ (void)decimal2string((decimal_t*) val, buff, &length, 0,0,0);
+ return buff;
}
-#endif
+#endif /*DBUG_OFF*/
#endif /*MYSQL_CLIENT*/