深度学习C++数据处理

demo1:

#include <iostream>

int main(){
    using namespace std;
    int n_int = INT_MAX;
    short n_short = SHRT_MAX;
    long n_long = LONG_MAX;
    long long n_llong = LLONG_MAX;

    // sizeof operator yield size of type or of variable
    cout << sizeof(int) << endl;
    cout << sizeof(short) << endl;
    cout << sizeof(long) << endl;
    cout << sizeof(long long) << endl;
    cout << sizeof n_llong<< endl;
    
    //maximum values
    cout << "int:" << n_int<< endl;
    cout << "short:" << n_short<< endl;
    cout << "long:" << n_long<< endl;
    cout << "long long:" << n_llong<< endl;

}

输出:

D:\C++Test\cmake-build-debug\C__Test.exe
4
2
4
8
8
int:2147483647
short:32767
long:2147483647
long long:9223372036854775807

Process finished with exit code 0
  • 无符号类型
    如果short表示范围 -32768~+32767,则无符号表四范围0-65535

  • char类型
    char用于C或C++中定义字符型变量,只占一个字节,取值范围为 -128 ~ +127(-27~27-1),char型数据是计算机编程语言中只可容纳单个字符的一种基本数据类型。
    取值范围:
    signed char: -2^7 ~ 2^7-1
    unsigned char : 0 ~ 2^8-1
    整型与字符型:整型和字符型是互通的,他们是在内存中存储的本质是相同的,只是存储的范围不同而已,整型可以是2字节,4字节,8字节,而字符型只占1字节。

  • 浮点数
    2种书写方式:
    12.34
    2.52e+8
    浮点类型有float,double,long double

  • 运算符重载
    使用相同的符号进行多种操作叫做运算符重载

  • 类型转换
    将浮点型转为整型时,C++采取截取而不是四舍五入

猜你喜欢

转载自blog.csdn.net/alspd_zhangpan/article/details/107482606
今日推荐