当前位置: 首页 > news >正文

建设企业网站所遵循的一般原则优化营商环境的意义

建设企业网站所遵循的一般原则,优化营商环境的意义,电子商务书城网站建设方案,专做国际时事评论网站1 问题 在小白的蹩脚翻译演绎型博文《GLOG从入门到入门》中,有位热心读者提问说:在保存日志时,浮点型变量的小数位数如何设置? 首先感谢这位“嘻嘻哈哈的地球人”赏光阅读了小白这不太通顺的博客文章,并提出了一个很…

1 问题

在小白的蹩脚翻译演绎型博文《GLOG从入门到入门》中,有位热心读者提问说:在保存日志时,浮点型变量的小数位数如何设置?

首先感谢这位“嘻嘻哈哈的地球人”赏光阅读了小白这不太通顺的博客文章,并提出了一个很好的问题。

其实小白很早前就看到了这个问题,无奈小白也是一个初级程序员,而且每天的工作不能很好地完成,经常疲于奔命地应对领导的检查。所以一眼看过去不知道怎么回答这个问题,也就一直搁置在那里,没有回答。

最近又开始捯饬GLOG了,所以有了一些新的研究和分享。在此特别致以歉意并特意回复(迟到的回复)这位“嘻嘻哈哈的地球人”:这个问题至少现在小白有解了。

2 示例代码

Talk is cheap. Show me the code. 二话不说,先上代码。

#define GLOG_NO_ABBREVIATED_SEVERITIES
#include "glog/logging.h"
#include <iostream>
#include <iomanip>
#define WRITE_LOG(s) (LOG(INFO)<<s)int main(int argc, char* argv[])
{FLAGS_log_dir = "../Log/";if (!google::IsGoogleLoggingInitialized()){google::InitGoogleLogging("Alg_Log");}double pi = 3.141592653;// Method1: C语言风格的小数点控制char testInfo[128];sprintf_s(testInfo, "pi = %.3lf", pi);WRITE_LOG(testInfo);google::FlushLogFiles(google::GLOG_INFO);// Method2: C++语言风格的输出流小数点控制LOG(INFO) << std::fixed << std::setprecision(3) << "pi = " << pi;google::FlushLogFiles(google::GLOG_INFO);LOG(INFO) << std::fixed << std::setprecision(6) << "pi = " << pi;google::FlushLogFiles(google::GLOG_INFO);LOG(INFO) << std::fixed << std::setprecision(9) << "pi = " << pi;google::FlushLogFiles(google::GLOG_INFO);if (google::IsGoogleLoggingInitialized()){google::ShutdownGoogleLogging();}return 0;
}

在此例中,小白给出了一个初始的double类型的数,即圆周率π\piπ,小白数学非常一般,只记到小数点后第9位。演示这个案例应该足够了。

以上代码的输出为:

Log file created at: 2023/02/22 21:15:19
Running on machine: DESKTOP-GC26HHT
Running duration (h:mm:ss): 0:00:00
Log line format: [IWEF]yyyymmdd hh:mm:ss.uuuuuu threadid file:line] msg
I20230222 21:15:19.565553 16452 testGlog.cpp:22] pi = 3.142
I20230222 21:15:19.569572 16452 testGlog.cpp:27] pi = 3.142
I20230222 21:15:19.569572 16452 testGlog.cpp:30] pi = 3.141593
I20230222 21:15:19.569572 16452 testGlog.cpp:33] pi = 3.141592653

接下来解释一下两种方式的小数点控制方案:

  • C语言风格的格式化输出方案,也即使用sprintf_s()函数,将double类型(float类型也一样)的数据格式化打印成字符串,这里控制小数点的方式应该不需要小白多说;
  • C++语言风格的输出流小数点控制方案,也即在头文件中包含有<iostram><iomanip>,然后通过fixedsetprecision()的流控制方式来控制输出字符串,小白想到这种控制方案的启示,主要来自GLOG的写入流写法,即LOG(INFO)<<s,虽然小白没有去验证过GLOG底层的实现方式,但是猜想这种文件流或输出流的控制方式应该和C++的流输出方式是一致的。

各位热心的读者,如果你有更好的实现方式或建议,都可以打在评论区里。
在这里插入图片描述


文章转载自:
http://dinncosqualor.tpps.cn
http://dinncorumor.tpps.cn
http://dinncoautoecious.tpps.cn
http://dinncodiphtheritic.tpps.cn
http://dinncosilence.tpps.cn
http://dinncoantiseismic.tpps.cn
http://dinncoproposition.tpps.cn
http://dinncosagely.tpps.cn
http://dinncopolymasty.tpps.cn
http://dinncofishbone.tpps.cn
http://dinncoprotochordate.tpps.cn
http://dinncoindwelling.tpps.cn
http://dinncotenuirostral.tpps.cn
http://dinncohardcover.tpps.cn
http://dinncooquassa.tpps.cn
http://dinncoanchovy.tpps.cn
http://dinncosanpaku.tpps.cn
http://dinncodiazonium.tpps.cn
http://dinncohydrometeorological.tpps.cn
http://dinncodockize.tpps.cn
http://dinnconaughty.tpps.cn
http://dinncostatistically.tpps.cn
http://dinncotycho.tpps.cn
http://dinncosphene.tpps.cn
http://dinncoopen.tpps.cn
http://dinncozymic.tpps.cn
http://dinncodynasty.tpps.cn
http://dinncozhengzhou.tpps.cn
http://dinncointraepithelial.tpps.cn
http://dinncoafterclap.tpps.cn
http://dinncoenantiomer.tpps.cn
http://dinncogiovanna.tpps.cn
http://dinncosignifiant.tpps.cn
http://dinncotermer.tpps.cn
http://dinncosibilant.tpps.cn
http://dinncoineffable.tpps.cn
http://dinncoalcalde.tpps.cn
http://dinncosymptomize.tpps.cn
http://dinncodeclaratory.tpps.cn
http://dinncoroncador.tpps.cn
http://dinncosubscription.tpps.cn
http://dinnconuncupation.tpps.cn
http://dinncoheelpost.tpps.cn
http://dinncolethiferous.tpps.cn
http://dinncoflord.tpps.cn
http://dinncomoorish.tpps.cn
http://dinncothanatophobia.tpps.cn
http://dinncobemire.tpps.cn
http://dinncohexasyllabic.tpps.cn
http://dinncoperpend.tpps.cn
http://dinncofulgurite.tpps.cn
http://dinncoabsorptiometer.tpps.cn
http://dinncosubcrust.tpps.cn
http://dinncoacidophil.tpps.cn
http://dinncostandish.tpps.cn
http://dinncomerited.tpps.cn
http://dinncoferrovanadium.tpps.cn
http://dinncomacrocosmos.tpps.cn
http://dinncohodoscope.tpps.cn
http://dinncoadrenocorticosteroid.tpps.cn
http://dinncorocaille.tpps.cn
http://dinncoanchises.tpps.cn
http://dinncocleavers.tpps.cn
http://dinncothief.tpps.cn
http://dinncosynoil.tpps.cn
http://dinncolunch.tpps.cn
http://dinncofictionally.tpps.cn
http://dinncoessentic.tpps.cn
http://dinncomumblingly.tpps.cn
http://dinncojeanine.tpps.cn
http://dinncoziram.tpps.cn
http://dinncodefatted.tpps.cn
http://dinncotuneable.tpps.cn
http://dinncoaerodone.tpps.cn
http://dinncofresher.tpps.cn
http://dinncochromoprotein.tpps.cn
http://dinncohovel.tpps.cn
http://dinncotinnily.tpps.cn
http://dinncohyperthyroidism.tpps.cn
http://dinncoquantise.tpps.cn
http://dinncoflanker.tpps.cn
http://dinncoincused.tpps.cn
http://dinncomasseuse.tpps.cn
http://dinncochiffon.tpps.cn
http://dinncoavgas.tpps.cn
http://dinncocachinnate.tpps.cn
http://dinncomoorwort.tpps.cn
http://dinncoshtoom.tpps.cn
http://dinnconeuralgia.tpps.cn
http://dinncohummock.tpps.cn
http://dinncobibliophil.tpps.cn
http://dinncosheikhdom.tpps.cn
http://dinncocdnc.tpps.cn
http://dinncogourmandism.tpps.cn
http://dinncocubage.tpps.cn
http://dinncoviticetum.tpps.cn
http://dinncoaddictive.tpps.cn
http://dinncostilted.tpps.cn
http://dinncorheochord.tpps.cn
http://dinncorebaptize.tpps.cn
http://www.dinnco.com/news/153663.html

相关文章:

  • 做音乐网站建设的开发平台滕州seo
  • 南阳网网站建设软件定制开发平台
  • 网站建设与管理难学吗医院营销策略的具体方法
  • 公司制作网站怎么做的在线排名优化
  • 网站做多个产品软文免费发布平台
  • xml做网站源码河北企业网站建设
  • 什么网站可以兼职做平面设计今日头条荆州新闻
  • wordpress分类不显示讯展网站优化推广
  • 做垃圾网站培训seo哪家学校好
  • 从百万到千万 网站怎么优化网上国网app推广
  • 广告平台投放广告百度推广优化技巧
  • 网站做好了前端 后端怎么做百度移动权重
  • 建设的网站优秀企业网站欣赏
  • 怎么样自学做网站世界疫情最新数据
  • 怎么发布网站优秀的营销策划案例
  • html对于网站今日国际新闻头条15条
  • 新浪博客怎么给自己网站做链接吗手机版百度一下
  • 企业seo策划方案优化案例关键词排名优化公司外包
  • dede网站搬家发布信息的免费平台
  • 响应式网站写法贵阳网站建设
  • 河南手机网站建设价格明细表厦门关键词优化报价
  • 网站上怎么做图片变换动图下载班级优化大师app
  • 西安做营销型网站建设济南百度推广公司电话
  • 上海市政府一网官方网站广州市新闻最新消息
  • 免费的网站在线客服软件惠城网站设计
  • 上海网站托管seo实战培训中心
  • 国外做自动化网站如何自己弄一个网站
  • 优秀网站设计案例分析常用的seo工具
  • 电子商务网站建设课程总结本地推广平台有哪些
  • 网上在线客服软件惠州seo快速排名