欢迎光临
我们一直在努力

2.3 数据类型 – 整型

说明: 整型变量表示整数类型的数字类型,比如-2, -1, 0 , 1, 2, 3

不同的数据类型,所需要的占用内存空间大小不一样

指定数据类型:等于指定的数据的范围和内存占用的空间大小,有效的利用内存空间,节约内存。

数据类型内存空间数据范围
char(最小整型)1个字节-128 ~ 127, (-2^7 ~ 2^7-1)
uchar(非负数字符型)1个字节0 ~ 255, (2^8-1)
short (短整型)2个字节-32768 ~ 32767, (-2^15 ~ 2^15-1)
ushort (非负数短整型)2个字节0 ~ 65535, (2^16-1)
int (整型)4个字节- 2,147,483,648 ~ 2,147,483,647, (-2^31 ~ 2^31-1)
uint (非负数整型)4个字节0 ~ 4,294,967,295, (2^32-1)
long(长整型)8个字节-9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807, (-2^63 ~ 2^63-1)
ulong(非负数长整型)8个字节0 ~ 18,446,744,073,709,551,615, (2^64-1)
#property copyright "Copyright 2022, Author:阿龙."
#property link      "https://www.guapit.com"
#property description "MT5智能交易编程课程"
#property description "QQ: 8199231"
#property version   "1.00"

void OnStart()
  {
    // char: 最小的整型
    char c1 = 10;
    // Print("c1的值: " + c1);
    
    // char的最大值: 127
    char c2 = 127;
    // Print("c2的值: " + c2);
    
    // char的最小值:-128
    char c3 = -128;
    // Print("c3的值: " + (string)c3);
    
    // uchar 非负数的整型
    uchar c4 = -10;
    Print("c4的值: " + (string)c4);
    
       // short: 短整型
   short s1 = 6666;
   // Print("s1的值=" + (string)s1);
   
   // ushort: 非负数短整型
   ushort s2 = 65535;
   // Print("s2的值=" + (string)s2);
   
   // int: 整型
   int a1 = 2147483647;
   // Print("a1的值=" + (string)a1);
   
   // uint: 非负数整型
   uint a2 = 4294967295;
   // Print("a2的值=" + (string)a2);
   
   // long: 长整型
   long l1 = 9223372036854775807;
   // Print("l1的值=" + (string)l1);
   
   // ulong: 非负数长整形
   ulong l2 = 18446744073709551615;
   Print("l2的值=" + (string)l2);
  }

 收藏 (0) 打赏

您可以选择一种方式赞助本站

支付宝扫一扫赞助

微信钱包扫描赞助

未经允许不得转载:瓜皮猫量化编程 » 2.3 数据类型 – 整型
分享到: 生成海报

评论 抢沙发

瓜皮猫量化交易编程

QQ群: 492653640微信: guapitcom
切换注册

登录

忘记密码 ?

切换登录

注册

我们将发送一封验证邮件至你的邮箱, 请正确填写以完成账号注册和激活