Java 6 - Creating and detecting the first Double value above Float.MAX_VALUE

非 Y 不嫁゛ 提交于 2019-12-08 06:57:26
Math.nextUp((double) Float.MAX_VALUE);

It's not only equivalent to the most efficient solution, but...it makes it pretty obvious what result you should expect.

Double val = (double)Float.MAX_VALUE;
val += Math.ulp(val);

This may also work (correction of your example), but not entirely sure:

Double val = Double.longBitsToDouble(Double.doubleToLongBits(Float.MAX_VALUE)+1);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!