正确的方法获得最负面的双重 [英] Correct Way to Obtain The Most Negative Double

查看:92
本文介绍了正确的方法获得最负面的双重的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是获取Java中最负面双倍的正确方法吗?

Is this the correct way to obtain the most negative double in Java?

double v = -Double.MAX_VALUE;


推荐答案

假设你的意思是最大的负数,非无限数,听起来是正确的,因为,对于 64位IEEE 754浮点数(其中的浮点数)是 Java用于双打):

Assuming you mean the largest negative, non-infinite number, sounds correct because, for floating point numbers in 64-bit IEEE 754 floating point (which is what Java uses for doubles):


  • 数字的大小存储在二进制代表的一部分中

  • 数字的符号是存储在二进制代表的单独部分中

因此:
最大可表示的负数与最大可表示正数相同,符号位翻转表示负数。

Therefore: The largest representable negative number would be the same as the largest representable positive number with the sign bit flipped to indicate a negative number.

这篇关于正确的方法获得最负面的双重的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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