Java中的快速sqrt以牺牲精度为代价 [英] Fast sqrt in Java at the expense of accuracy

查看:238
本文介绍了Java中的快速sqrt以牺牲精度为代价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找Java中的快速平方根实现,用于输入范围为[0,2 * 10 ^ 12]的双值。对于此范围内的任何值,精度应小于5位小数。换句话说,结果可能与5位小数后的 Math.sqrt()方法不同。但是,此方法需要比 Math.sqrt()快得多。

I am looking for a fast square root implementation in Java for double values in the input range of [0, 2*10^12]. For any value in this range, the precision should be upto 5 decimal places. In other words, the result can differ from the Math.sqrt() method after 5 decimal places. However, this method needs to be much faster than Math.sqrt().

任何想法?谢谢!

推荐答案

我不相信(没有基准来证明这是错误的)纯Java实现可以 Math.sqrt()快得多 Oracle JRE实施 OpenJDK实现是本机实现。

I don't believe (without a benchmark to prove this wrong) that a pure Java implementation could me much faster than Math.sqrt(). Both the Oracle JRE implementation and the OpenJDK implementation are native implementations.

这篇关于Java中的快速sqrt以牺牲精度为代价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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