首页
社区
课程
招聘
请问这个是什么算法?
发表于: 2010-2-23 14:48 3683

请问这个是什么算法?

2010-2-23 14:48
3683
每一步都能看懂,但结果挺糊涂的,根据结果来看似乎是开根号,是吗
请问里边的两个循环分别是干什么的呢?

[课程]Linux pwn 探索篇!

上传的附件:
收藏
免费 0
支持
分享
最新回复 (8)
雪    币: 13
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
没有看懂啦········
2010-2-23 15:06
0
雪    币: 458
活跃值: (421)
能力值: ( LV9,RANK:610 )
在线值:
发帖
回帖
粉丝
3
烦请把左边的地址栏也给出来好么
这样我哪知道那几个跳转是跳哪去的?
2010-2-23 15:53
0
雪    币: 87
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
切割多了,没注意,呵呵,更新了图片了
2010-2-23 16:11
0
雪    币: 119
活跃值: (10)
能力值: ( LV9,RANK:160 )
在线值:
发帖
回帖
粉丝
5
下面这段是在2的N次方中,取比被开放数的平方根略大的数(提高效率的作用)
LABLE1:(0048DE40)
ADD ECX, ECX
SHR ESI, 1
CMP ECX, ESI
JB SHORT LABLE1

从比较接近平方根的数开始,不断的接近平方根(取整),直到最接近为止。

NearSquareRoot = (radicand / NearSquareRoot + NearSquareRoot) /2
NearSquareRoot会越来越接近平方根

LABLE2:(0048DE48)
MOV EAX, EDI
XOR EDX, EDX
DIV ECX
MOV ESI, ECX
ADD EAX, ECX
SHR EAX, 1
MOV ECX, EAX
CMP ECX, ESI
JB LABLE2
2010-2-23 19:53
0
雪    币: 119
活跃值: (10)
能力值: ( LV9,RANK:160 )
在线值:
发帖
回帖
粉丝
6
好久不写代码了,简单的用c实现一下:
#include "stdio.h"

int main()
{

int num = 0, SquareRoot = 1;
int s = 0, n = 0;
int NearSquareRoot, NearSquareRootBat;

printf("Input radicand(输入被开放数): ");
scanf("%d", &num);

if(SquareRoot < num)
{
n = num;
s = SquareRoot;

while( s < n)
{
s *= 2;
n /= 2;
}
NearSquareRoot = s;
}

printf("NearSquareRoot: %d\n", NearSquareRoot);

do
{
NearSquareRootBat = NearSquareRoot;
NearSquareRoot = (num / NearSquareRoot + NearSquareRoot) /2;
}
while(NearSquareRootBat > NearSquareRoot);

SquareRoot = NearSquareRootBat;
printf("Round SquareRoot(平方根取整): %d\n", SquareRoot);


return 0;
}
2010-2-23 19:54
0
雪    币: 458
活跃值: (421)
能力值: ( LV9,RANK:610 )
在线值:
发帖
回帖
粉丝
7
学习了   犀利的编译器的优化
2010-2-23 23:27
0
雪    币: 87
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
一个字:犀利。。
哈哈,长见识了,谢谢
2010-2-24 09:44
0
雪    币: 201
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
真没看懂...0 0
2010-2-26 18:36
0
游客
登录 | 注册 方可回帖
返回
//