你怎么能轻松地长长计算一个无符号的平方根用C? [英] How can you easily calculate the square root of an unsigned long long in C?

查看:212
本文介绍了你怎么能轻松地长长计算一个无符号的平方根用C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找另外一个问题(<一个href=\"http://stackoverflow.com/questions/8808940/x86-assembly-masm-square-root-of-a-64-bit-integer\">here)如果有人一直在寻找一种方式来获得一个64位整数的平方根x86汇编。

I was looking at another question (here) where someone was looking for a way to get the square root of a 64 bit integer in x86 assembly.

这原来是非常简单的。解决的办法是转换为一个浮点数,计算平方根,然后再转换回来。

This turns out to be very simple. The solution is to convert to a floating point number, calculate the sqrt and then convert back.

我需要做用C非常相似但是当我看着等值我开始有点卡住的东西。我只能找到一个平方根函数,它接受双打。双打没有precision存储大整数的64位不引入显著舍入误差。

I need to do something very similar in C however when I look into equivalents I'm getting a little stuck. I can only find a sqrt function which takes in doubles. Doubles do not have the precision to store large 64bit integers without introducing significant rounding error.

有一个共同的数学库,我可以使用具有长双 sqrt函数?

Is there a common math library that I can use which has a long double sqrt function?

推荐答案

功能 sqrtl(),采取了长双,是C99的一部分。

Function sqrtl(), taking a long double, is part of C99.

请注意,你的编译平台不具备实施长双 80位的延伸期precision。它只要求是一样宽双击,和Visual Studio工具是作为一个普通的双击。 GCC和锵也编长双来英特尔处理器的80位延伸期precision。

Note that your compilation platform does not have to implement long double as 80-bit extended-precision. It is only required to be as wide as double, and Visual Studio implements is as a plain double. GCC and Clang do compile long double to 80-bit extended-precision on Intel processors.

这篇关于你怎么能轻松地长长计算一个无符号的平方根用C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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