未验证 提交 d63a39f5 编写于 作者: 羽飞's avatar 羽飞 提交者: GitHub

add fload print function (#88)

上级 89d57d85
......@@ -16,6 +16,7 @@ See the Mulan PSL v2 for more details. */
#include "storage/common/field.h"
#include "common/log/log.h"
#include "util/comparator.h"
#include "util/util.h"
void TupleCell::to_string(std::ostream &os) const
{
......@@ -24,7 +25,8 @@ void TupleCell::to_string(std::ostream &os) const
os << *(int *)data_;
} break;
case FLOATS: {
os << *(float *)data_;
float v = *(float *)data_;
os << double2string(v);
} break;
case CHARS: {
for (int i = 0; i < length_; i++) {
......
/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved.
miniob is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details. */
//
// Created by wangyunlai on 2022/9/28
//
#include <string.h>
#include "util/util.h"
std::string double2string(double v)
{
char buf[256];
snprintf(buf, sizeof(buf), "%.2f", v);
size_t len = strlen(buf);
while (buf[len - 1] == '0') {
len--;
}
if (buf[len - 1] == '.') {
len--;
}
return std::string(buf, len);
}
/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved.
miniob is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details. */
//
// Created by wangyunlai on 2022/9/28
//
#pragma once
#include <string>
std::string double2string(double v);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册