---
title: "J2ME快速开平方根"
author: "rayloo"
date: "2007-09-30T14:16:00Z"
tags: []
slug: "j2me"
draft: false
lastmod: "2007-09-30T14:16:00Z"
id: 1008884
url: "https://rayloo.iteye.com/blog/1008884"
---

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)/\*\*\*//\**  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)\*求平方根  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)\*@paramvalue定义域  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)\*@return值域  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)\*/  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)finalpublicstaticintsqrt(intvalue)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)intsqrt=0;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)for(intk=0x100000;k!=0;k&gt;&gt;=2)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)inttmp=sqrt+k;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sqrt&gt;&gt;=1;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)if(tmp&lt;=value)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)value-=tmp;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sqrt+=k;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)returnsqrt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)}