由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 请教谁会算浮点数的开方?
相关主题
Google到底需要什么样的人才?对于10+工作经验的人flg面试考os,db,tcp/ip这些吗?
关于改简历的问题how to calculate sqrt double?
来贡献个facebook phone 题吧在Java,怎样做floating point number 的比较?
leetcode:这题 int sqrt(int)??!!为啥用int问一道面试智力题
square root的算法急问有没有面试过bloomberg的senior calculations programmer的?
求分析这题的时间复杂度about how to test a calculator program on computer
bloomberg onsite 面经 +offera公司面筋 + 求a公司各个组介绍
请教FB on-site 面试题请教一道有关随机函数的面试问题
相关话题的讨论汇总
话题: dbend话题: dbmid话题: dbbeg话题: double话题: dbsqrdiff
进入JobHunting版参与讨论
1 (共1页)
l****c
发帖数: 782
1
Write a Square Root function for a computer without floating point
calculations?
无从下手啊。。。。。
w****x
发帖数: 2483
2
//Write a program to find the square root of a given numbe
//Binary search again.
double GetSquareRoot(double f, double exp)
{
assert((f > 0.0 || abs(f) < exp) && exp > 0.0);
double dbBeg = 0.0;
double dbEnd = f;
if (f < 1.0) dbEnd = 1.0;
int nCount = 100;
do
{
double dbMid = (dbBeg + dbEnd)/2.0;
double dbSqrDiff = dbMid*dbMid - f;
if (abs(dbSqrDiff) < exp)
break;
if (dbSqrDiff < 0.0)
dbBeg = dbMid;
else
dbEnd = dbMid;
} while (nCount-- >= 0);
return (dbBeg + dbEnd)/2.0;
}
l****c
发帖数: 782
3
但是要求without floating point calculation怎么办呢大牛?

【在 w****x 的大作中提到】
: //Write a program to find the square root of a given numbe
: //Binary search again.
: double GetSquareRoot(double f, double exp)
: {
: assert((f > 0.0 || abs(f) < exp) && exp > 0.0);
: double dbBeg = 0.0;
: double dbEnd = f;
: if (f < 1.0) dbEnd = 1.0;
: int nCount = 100;
: do

f*****e
发帖数: 2992
4
看看汇编和linux内核是怎么算sqrt的。隔壁programming版就有。

【在 l****c 的大作中提到】
: Write a Square Root function for a computer without floating point
: calculations?
: 无从下手啊。。。。。

w****x
发帖数: 2483
5

那只有问北二牛了

【在 l****c 的大作中提到】
: 但是要求without floating point calculation怎么办呢大牛?
1 (共1页)
进入JobHunting版参与讨论
相关主题
请教一道有关随机函数的面试问题square root的算法
扔鸡蛋的问题求分析这题的时间复杂度
跟风吐槽zenefitsbloomberg onsite 面经 +offer
问一道最简单的题 把一个数拆成任意个平方和的最小拆法请教FB on-site 面试题
Google到底需要什么样的人才?对于10+工作经验的人flg面试考os,db,tcp/ip这些吗?
关于改简历的问题how to calculate sqrt double?
来贡献个facebook phone 题吧在Java,怎样做floating point number 的比较?
leetcode:这题 int sqrt(int)??!!为啥用int问一道面试智力题
相关话题的讨论汇总
话题: dbend话题: dbmid话题: dbbeg话题: double话题: dbsqrdiff