为什么负值会在乘法后很长时间内出现? [英] Why negative value comes for long after multiplication?

查看:153
本文介绍了为什么负值会在乘法后很长时间内出现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么java中的这段代码会给出负值?

Why this code in java gives negative value?

    long ttt = (60 * 60 * 1000 * 24 * 26);
    System.out.println(ttt);

结果出现在eclipse控制台上 -2134967296

Result which comes as on eclipse console -2134967296?

我在做什么傻事,可能是它超出了我的范围吗?

Anything silly I am doing, may be it crossed int range I guess?

推荐答案

因为 60 * 60 * 1000 * 24 * 25 溢出 int 范围。

将其中一个设为,以便促销发生

Make one of them a long so that promotion occurs

60L * 60 * 1000 * 24 * 25

这篇关于为什么负值会在乘法后很长时间内出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆