hikyuu2/hikyuu_cpp/hikyuu/utilities/util.h

66 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* util.h
*
* Created on: 2009-11-20
* Author: fasiondog
*/
#pragma once
#ifndef HIKYUU_UTILIIES_UTIL_H_
#define HIKYUU_UTILIIES_UTIL_H_
#include <string>
#ifndef HKU_API
#define HKU_API
#endif
namespace hku {
/**
* @ingroup Utilities
* @{
*/
#if defined(_MSC_VER)
std::string HKU_API utf8_to_gb(const char* szinput);
std::string HKU_API utf8_to_gb(const std::string& szinput);
std::string HKU_API gb_to_utf8(const char* szinput);
std::string HKU_API gb_to_utf8(const std::string& szinput);
#else
std::string HKU_API utf8_to_gb(const std::string& szinput);
std::string HKU_API gb_to_utf8(const std::string& szinput);
#endif
#define UTF8ToGB utf8_to_gb
#define GBToUTF8 gb_to_utf8
/**
* 四舍五入ROUND_HALF_EVEN 银行家舍入法
* @param number 待四舍五入的数据
* @param ndigits 保留小数位数
* @return 处理过的数据
*/
double HKU_API roundEx(double number, int ndigits = 0);
/**
* 向上截取如10.1截取后为11
* @param number 待处理数据
* @param ndigits 保留小数位数
* @return 处理过的数据
*/
double HKU_API roundUp(double number, int ndigits = 0);
/**
* 向下截取如10.1截取后为10
* @param number 待处理数据
* @param ndigits 保留小数位数
* @return 处理过的数据
*/
double HKU_API roundDown(double number, int ndigits = 0);
/** @} */
} // namespace hku
#endif /* HIKYUU_UTILIIES_UTIL_H_ */