From 9b142b9f6fe65cd427980eed46f32e476cbb965a Mon Sep 17 00:00:00 2001 From: "HuYingzhuo(hugo/hyzboy)" Date: Wed, 26 Jul 2023 22:26:03 +0800 Subject: [PATCH] added String::percentOf --- inc/hgl/type/StrChar.h | 3 ++- inc/hgl/type/String.h | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/inc/hgl/type/StrChar.h b/inc/hgl/type/StrChar.h index 0eed054..29c6d7c 100644 --- a/inc/hgl/type/StrChar.h +++ b/inc/hgl/type/StrChar.h @@ -524,6 +524,7 @@ namespace hgl * @param str2 要查找的字符串 * @param size2 str2的长度 * @return str2在str1中所在位置的指针 + * @return nullptr 没有找到 */ template T1 *stristr(T1 *str1,const uint size1,T2 *str2,const uint size2) @@ -568,7 +569,7 @@ namespace hgl ++cp; } - return(0); + return(nullptr); } /** diff --git a/inc/hgl/type/String.h b/inc/hgl/type/String.h index 9c3096c..eca7e90 100644 --- a/inc/hgl/type/String.h +++ b/inc/hgl/type/String.h @@ -153,6 +153,12 @@ namespace hgl #undef BASE_STRING_FLOAT_CONSTRUCT + template + static String percentOf(const N1 numerator,const N2 denominator,const uint frac_num) + { + return String::floatOf(double(numerator)/double(denominator)*100.0f,frac_num); + } + String(const int *value,int N)=delete; static String numberOf(const int *value,int N)