24 #include <drizzled/error.h>
25 #include <drizzled/field.h>
26 #include <drizzled/item/float.h>
27 #include <drizzled/item/num.h>
28 #include <drizzled/item/string.h>
32 extern const charset_info_st *system_charset_info;
34 static uint32_t nr_of_decimals(
const char *str,
const char *end)
36 const char *decimal_point;
43 if (*str ==
'e' || *str ==
'E')
49 for (; system_charset_info->isdigit(*str) ; str++)
51 if (*str ==
'e' || *str ==
'E')
53 return (uint32_t) (str - decimal_point);
60 str->set_real(value,decimals,&my_charset_bin);
68 if (value <= (
double) INT64_MIN)
72 else if (value >= (
double) (uint64_t) INT64_MAX)
76 return (int64_t) rint(value);
83 double2_class_decimal(E_DEC_FATAL_ERROR, value, decimal_value);
84 return (decimal_value);
96 value= my_strntod(&my_charset_bin, (
char*) str_arg, length, &end_not_used,
104 assert(str_arg[length] == 0);
105 my_error(ER_ILLEGAL_VALUE_FOR_TYPE, MYF(0),
"double", (
char*) str_arg);
107 presentation=
name=(
char*) str_arg;
108 decimals=(uint8_t) nr_of_decimals(str_arg, str_arg+length);
113 int Item_float::save_in_field(
Field *field,
bool)
117 return set_field_to_null(field);
118 field->set_notnull();
119 return field->store(nr);
127 str->append(presentation, strlen(presentation));
131 String num(buffer,
sizeof(buffer), &my_charset_bin);
132 num.set_real(value, decimals, &my_charset_bin);
159 String tmp(buf,
sizeof(buf), &my_charset_bin);
virtual bool basic_const_item() const
Item_float(const char *str_arg, uint32_t length)
bool eq(const Item *, bool binary_cmp) const
TODO: Rename this file - func.h is stupid.
String * val_str(String *)
virtual double val_real()=0
type::Decimal * val_decimal(type::Decimal *)
virtual void print(String *str)