当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·windowsxp出现新问题(在线等待)    »显示摘要«
    摘要: 每当进入xp后桌面上的快捷方式全没了,并且任务栏也没了,在桌面点击鼠标左右键也弹不出任何对话框.只是一进入xp后就弹出一个对话框(就是没出现此问题时点击我的电脑的快捷方式时弹出的那种).请问这是为什么 ......
    摘要: 我建立了一个对话框程序 其中有个editbox 我想在程序中,editbox里输入用户名字,再将字符串存到一个变量里,怎么操作? 程序一开始,就建立了3个类 caboutdlg croeditapp croeditdlg 我的变量应建立在哪个类里?请具体说说对话框当中,控件如何操作~谢谢~ ......


如何控制浮点型精度

我在jsp中有以下几句语句:  
  <script   language=javascript>  
  x=a/b;  
   
  </script>  
   
  现在所得x的精度很高我想问一下怎么样才能使它转化为精度为1.00这样的数值或字符串都有行.  
  注意:是在客户端脚本,不是服务端脚本!  
 

NO.1   作者: fu_gui

Number.toFixed(fracDigits)   fracDigits为小数点后的位数,只在IE5.5以上可行  
  IE5.5以下我用的是s=Number.toString();   s=s.substr(0,s.indexOf(.)+fracDigits);

NO.2   作者: youbest

用VBScript来处理最方便.  
   
  <Script   language=VBScript>  
  x=a/b;  
  MsgBox(FormatNumber(x,2))  
  </Script>

NO.3   作者: xinyunyishui

<script>  
  String.prototype.fn   =   function(n)  
      {   s=""  
          for(i=0;i<n;i++)s+=this  
          return   s  
      }  
  Number.prototype.fix   =   function(num)  
      {with(Math)return   (round(this.valueOf()*pow(10,num))/pow(10,num)).toString().search(/\./i)==-1?(round(this.valueOf()*pow(10,num))/pow(10,num)).toString()+"."+"0".fn(num):(round(this.valueOf()*pow(10,num))/pow(10,num));  
      }  
  alert((5.31-1.31).fix(2));  
  </script>  
  上边的代码返回任意数的保留n位小数值,为了考虑货币的效果形势,所以长了一点儿,因为4.00的格式是不能显示的,如果不用顾及那个用下边的就行  
  <script>  
  Number.prototype.fix   =   function(num)  
      {with(Math)return   round(this.valueOf()*pow(10,num))/pow(10,num);  
      }  
  alert((5.31-1.31).fix(2));  
  </script>

NO.4   作者: fason

<script>  
  function   Number.prototype.Fixed(num){  
  with(Math){  
  var   m=pow(10,Number(num))  
  return   round(this*m)/m;  
  }  
  }  
  alert((2/3).Fixed(2))  
  alert((2/3).toFixed(2));//ie5.5+  
  </script>

NO.5   作者: xuzuning

通用的toFixed  
  <script>  
  try   {  
      Number.toFixed();  
  }  
  catch(e)   {  
      function   Number.prototype.toFixed(dot)   {  
          with(Math){  
              var   m=pow(10,Number(dot))  
              var   s   =   (round(this*m)/m).toString();  
          }  
          if(s.indexOf(.)   <   0)  
                s   +=   ".";  
          s   +=   "000000000000";  
          return   s.substr(0,s.indexOf(.)+dot+1);  
      }  
  }  
   
  alert((2/3).toFixed(2));  
   
  </script>  
 


    摘要: adoconnection.connectionstring有几种表示方式(用sql server 2000) 请列举,谢谢 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE