c语言long int double类型,Int,long,float,double类型

byte占1个字节,char占2个字节,short占2个字节,int占4个字节,long占8个字节,float占8个字节,double占16个字节。

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package test;

/**

*

* @author huanghuankun

*/

public class IntAndLong {

//int占4个字节,long占8个,float占8个,double占16个。

public static void main(String[] arg) {

int i_max = Integer.MAX_VALUE;

int i_min = Integer.MIN_VALUE;

System.out.println("int:max=" + i_max + ",min=" + i_min);

long l_max = Long.MAX_VALUE;

long l_min = Long.MIN_VALUE;

System.out.println("long:max=" + l_max + ",min=" + l_min);

double d_max = Double.MAX_VALUE;

double d_min = Double.MIN_VALUE;

System.out.println("double:max=" + d_max + ",min=" + d_min);

long lTmp = i_max + 1;

System.out.println("lTmp="+lTmp);

System.out.println("i_max+1="+(i_max+1));//溢出

System.out.println("i_min-1="+(i_min-1));

}

}输出结果:

int:max=2147483647,min=-2147483648

long:max=9223372036854775807,min=-9223372036854775808

double:max=1.7976931348623157E308,min=4.9E-324

lTmp=-2147483648

i_max+1=-2147483648

在进行数据运算过程中需要注意溢出问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值