本文整理汇总了C++中ObExprObj::set_double方法的典型用法代码示例。如果您正苦于以下问题:C++ ObExprObj::set_double方法的具体用法?C++ ObExprObj::set_double怎么用?C++ ObExprObj::set_double使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObExprObj
的用法示例。
在下文中一共展示了ObExprObj::set_double方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bool_double
static int bool_double(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
UNUSED(params);
OB_ASSERT(in.get_type() == ObBoolType);
out.set_double(static_cast<double> (in.get_bool()));
return OB_SUCCESS;
}
示例2: mtime_double
static int mtime_double(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
UNUSED(params);
OB_ASSERT(in.get_type() == ObModifyTimeType);
out.set_double(static_cast<double> (in.get_mtime()));
return OB_SUCCESS;
}
示例3: pdatetime_double
static int pdatetime_double(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
UNUSED(params);
OB_ASSERT(in.get_type() == ObPreciseDateTimeType);
out.set_double(static_cast<double> (in.get_precise_datetime()));
return OB_SUCCESS;
}
示例4: snprintf
TEST_F(ObObjCastTest, double_to_xxx)
{
ObExprObj in;
char buf[128];
double cases[] = {-1.1, 0.0, 1.1};
const char *dec_expected[] = {"-1.100000", "0", "1.100000"};
for (int64_t i = 0; i < static_cast<int64_t>(ARRAYSIZEOF(cases)); ++i)
{
double v = cases[i];
in.set_double(v);
snprintf(buf, 128, "%lf", v);
MY_EXPECT(ObDoubleType, in, ObNullType, v, buf);
MY_EXPECT(ObDoubleType, in, ObIntType, v, buf);
MY_EXPECT(ObDoubleType, in, ObFloatType, v, buf);
MY_EXPECT(ObDoubleType, in, ObDoubleType, v, buf);
MY_EXPECT(ObDoubleType, in, ObDateTimeType, v, buf);
MY_EXPECT(ObDoubleType, in, ObPreciseDateTimeType, v, buf);
MY_EXPECT(ObDoubleType, in, ObVarcharType, v, buf);
MY_EXPECT(ObDoubleType, in, ObSeqType, v, buf);
MY_EXPECT(ObDoubleType, in, ObCreateTimeType, v, buf);
MY_EXPECT(ObDoubleType, in, ObModifyTimeType, v, buf);
MY_EXPECT(ObDoubleType, in, ObExtendType, v, buf);
MY_EXPECT(ObDoubleType, in, ObBoolType, v, buf);
MY_EXPECT(ObDoubleType, in, ObDecimalType, v, dec_expected[i]);
}
}
示例5: varchar_double
static int varchar_double(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
int ret = OB_SUCCESS;
UNUSED(params);
OB_ASSERT(in.get_type() == ObVarcharType);
double value = 0.0;
ret = varchar_scanf(in, 1, "%lf", &value);
if (OB_SUCCESS == ret)
{
out.set_double(value);
}
else
{
out.set_double(0.0);
ret = OB_SUCCESS;
}
return ret;
}
示例6: decimal_double
static int decimal_double(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
UNUSED(params);
OB_ASSERT(in.get_type() == ObDecimalType);
// decimal -> string -> float
char buf[ObNumber::MAX_PRINTABLE_SIZE];
memset(buf, 0, ObNumber::MAX_PRINTABLE_SIZE);
in.get_decimal().to_string(buf, ObNumber::MAX_PRINTABLE_SIZE);
double v = 0.0;
if (1 == sscanf(buf, "%lf", &v))
{
out.set_double(v);
}
else
{
out.set_double(0.0);
}
return OB_SUCCESS;
}