首页 > 其他分享 >int,long,long long对应10的数量级

int,long,long long对应10的数量级

时间:2022-10-29 15:58:16浏览次数:45  
标签:10 int long 数量级 d2 对应

  刷题的时候,题目会给出变量的范围,这个时候就要想清楚用哪个类型

#include<iostream>
using namespace std;

int main(){
    int d2 = (1<<31)-1;
    int d0 = 10;
    long l2 = ((long)1<<31)-1;
    long l0 = 10;
    long long ll2 = ((long long)1<<63)-1;
    long long ll0 = 10;

    for(int i = 0; i<8; i++) d0*=10;//即10^9
    for(int i = 0; i<8; i++) l0*=10;//即10^9
    for(int i = 0; i<17; i++) ll0*=10;//即10^18    

    cout<< d2 << "  (int的最大值)" <<endl;
    cout<< d0 << "  (对应10^9)" <<endl;
    cout<< l2 << "  (long的最大值)" <<endl;
    cout<< l0 << "  (对应10^9)" <<endl;
    cout<< ll2 << "  (long long的最大值)" <<endl;
    cout<< ll0 << "  (对应10^18)" <<endl;
    return 0;
}

输出结果为:

​编辑​

标签:10,int,long,数量级,d2,对应
From: https://www.cnblogs.com/--OvO--/p/16838893.html

相关文章

  • 10.区块链系列之hardhat部署抵押赎回Fund合约
    本文继续通过笔者学习到的抵押赎回智能合约Fund来进一步学习solidity语言,加深对开发的理解,其中通过storage节省gas是需要重点实践的,毕竟涉及到资产代码已提交至https://gi......
  • L10U4-3 Presenting information
    VocabularyMorebusinesspresentationsDialogue[JOAN]Asyouknow,I'vebeenspendingalotoftimeatSunset'sheadquarters.AndI'vebeenveryimpressed.It's......
  • 前端项目实战107-前端中对action按钮的回调
    constbuttonFlag:any={0:()=>{//setCurrentMenu(null);setEditVisible(true);},1:()=>{//setCu......
  • STTH6010-Y-ASEMI原厂代理意法超快恢复二极管STTH6010-Y
    编辑-ZSTTH6010-Y用的TO-247-2L封装,是意法一款汽车用超快恢复高压二极管。STTH6010-Y的反向电流,漏电流(IR)为20uA,其工作时耐温度范围为-40~175摄氏度。STTH6010-Y的浪涌非重......
  • L10U4-2-Opening a presentation
    1ReadingPresentationtipsPresentationtipsYouareabouttoreadawebsitewithpointersforopeningapresentation.Beforeyouread,grouptheproblemsand......
  • [2022.10.29]常用类—基本数据类型和包装类
    Java提供了八种基本数据类型:byte、short、int、long、float、double、boolean、char,每种基本类型都有其对应的类基本数据类型对应包装类byteByteshortShort......
  • java学习 2022年10月29日13:26:28
    packagecn.tedu.type1;publicclassForDemo{publicstaticvoidmain(String[]args){outer:for(intj=1;j<10;j++){for(inti=0;i......
  • 第10章 评价分类结果
     10-1准确度的陷阱和混淆矩阵         ......
  • 1060 爱丁顿数
    英国天文学家爱丁顿很喜欢骑车。据说他为了炫耀自己的骑车功力,还定义了一个“爱丁顿数” E ,即满足有 E 天骑车超过 E 英里的最大整数 E。据说爱丁顿自己的 E 等于......
  • 2022.10.29-2021级王建民JAVA期中测试
     校园社团活动管理系统(20分)1、项目需求:校园社团作为高校课外活动的重要组成部分,发展十分迅速,也受到越来越多学生的欢迎,社团规模、数量等都在日益增长,社团活动也更为多......