00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021 #include <math.h>
00022 #include <drizzled/function/math/real.h>
00023
00024 namespace drizzled
00025 {
00026
00027
00028 String *Item_real_func::val_str(String *str)
00029 {
00030 assert(fixed == 1);
00031 double nr= val_real();
00032 if (null_value)
00033 return 0;
00034 str->set_real(nr,decimals, &my_charset_bin);
00035 return str;
00036 }
00037
00038
00039 type::Decimal *Item_real_func::val_decimal(type::Decimal *decimal_value)
00040 {
00041 assert(fixed);
00042 double nr= val_real();
00043 if (null_value)
00044 return 0;
00045 double2_class_decimal(E_DEC_FATAL_ERROR, nr, decimal_value);
00046 return decimal_value;
00047 }
00048
00049 int64_t Item_real_func::val_int()
00050 {
00051 assert(fixed == 1);
00052 return (int64_t) rint(val_real());
00053 }
00054
00055 void Item_real_func::fix_length_and_dec()
00056 {
00057 decimals= NOT_FIXED_DEC;
00058 max_length= float_length(decimals);
00059 }
00060
00061 }