Open
Description
tb_string_cstrfcat 输出浮点数Bug.
输出浮点数,显示有乱码. 代码如下
double t_HUGE_VAL = HUGE_VAL;
double t_HUGE_VALF = HUGE_VALF;
double t_HUGE_VALL = HUGE_VALL;
double t_NAN = NAN;
double x = 2318931208301238129083120832190.12212;
printf("%lf\n",t_HUGE_VALF);
printf("%lf\n",t_HUGE_VAL);
printf("%lf\n",t_HUGE_VALL);
printf("%lf\n",t_NAN);
printf("%lf\n",x);
printf("%.8e\n",x);
tb_string_t a_str;
tb_string_init(&a_str);
tb_string_cstrfcat(&a_str, "%lf,%lf,%lf,%lf %lf; %.8e\n", t_HUGE_VALF, t_HUGE_VAL, t_HUGE_VALL, t_NAN, x,x);
printf("%s",tb_string_cstr(&a_str));
tb_string_exit(&a_str);
输出
inf
inf
inf
nan
2318931208301238007236648763392.000000
2.31893121e+30
inf,inf,inf,nan '..--).0-*(+,))+(0(.000000; ./,),(-*,(.00000000
期待的结果
输出应该同printf 的输出相同.
错误信息
输出中出现了 ''..--).0-(+,))+(0(.000000; ./,),(-,(.00000000' 这样的乱码.
相关环境
gcc 7.2 ubuntu