zoukankan      html  css  js  c++  java
  • 【Boost】系列05:数值与字符串转换

    #include <boost/lexical_cast.hpp>
    #include <iostream>
    using namespace boost;
    using namespace std;
    
    int main()
    {
        int x = lexical_cast<int>("100");
        long y = lexical_cast<long>("2000"); 
        float pi = lexical_cast<float>("3.14159e5");
        double e = lexical_cast<double>("2.71828");
    
        cout<<"x="<<x<<"  y="<<y<<"  pi="<<pi<<"  e="<<e<<endl;
    
        string str = lexical_cast<string>(456);
        cout<<str<<endl;
        cout<<lexical_cast<string>(0.618)<<endl;
        cout<<lexical_cast<string>(0x10)<<endl;
    
        return 0;
    
    }

    输出:

    x=100  y=2000  pi=314159  e=2.71828

    456

    0.61799999999999999

    16

  • 相关阅读:
    nginx 安装配置
    mysql分表
    冲刺day7
    冲刺day6
    冲刺day5
    冲刺day4
    冲刺day3
    冲刺day2
    冲刺day1
    撰写《需求规格说明书》的工作流程、组员分工和组员工作量比例
  • 原文地址:https://www.cnblogs.com/elesos/p/2781293.html
Copyright © 2011-2022 走看看