The digital val rounding, and retain the decimal scale

 * The val rounded  , And retain scale decimal
function mathRound(val,scale){
    var base = 10;
    for(var i=1;i<scale;i++){
        base = base*10;
    var newVal = Math.round(val*base)/base;
    var rsplit = newVal.toString().split(".");
    var zeroNum = scale;
        zeroNum = scale-rsplit[1].length;
        newVal = newVal+".";
    for(var i=0;i<zeroNum;i++){
        newVal = newVal+"0";
    return newVal;
分类:Web 时间:2009-09-03 人气:221
本文关键词: lt math decimal scale
blog comments powered by Disqus


  • POJ 1894 Alternative Scale of Notation [JAVA operation of large numbers] 2010-05-31

    Alternative Scale of Notation Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1530 Accepted: 538 Description One may define a map of strings over an alphabet Σ B = (C1, C2,... C B) of size B to non-negative integer numbers, using character

  • CallableStatement Xiangjie 2010-09-16

    CallableStatement for the implementation of SQL stored procedures. JDBC provides a stored procedure SQL escape, it allows a standard way for all RDBMS stored procedure call. This escape syntax has a result parameter that contains the format and a for

  • Detailed CallableStatement 2010-09-16

    CallableStatement is used to execute SQL stored procedures. JDBC provides a stored procedure SQL escape, which allows a standard way to call all RDBMS stored procedures. This escape syntax has one parameter that contains the format and the result doe

  • Common abnormalities resolved 2011-09-18

    ConcurrentHashMap and CopyOnWriteArrayList comparison. Blog categories: Java ConcurrentHashMap ConcurrentHashMap introduced Segment, each Segment is a hashtable, the equivalent of two Hash table, and then lock in the Segment level, and increased conc

  • EJB 2009-02-27

    public transient int counter; / / transient property private String firstname; / / persistent property @ Transient String getLengthInMeter () (...) / / transient property String getName () (...) / / persistent property @ Basic int getLength () (...)

  • hibernate annontaion learn more 2010-04-07

    Hibernate Annotation Description Turn @ Entity public class Flight implements Serializable ( Long id; @ Id public Long getId () (return id;) public void setId (Long id) ( = id;) ) @ Entity annotation to a class dec

  • Image processing tools 2010-04-12

    In actual projects, we often encounter a variety of image processing problems. For example: image rotation, zooming, image format conversion, get image type, image size validation, write pictures. Here we use java.awt.Graphics2D to achieve common ima

  • HIbernate comment Xiangjie 2010-05-16

    @ Author liuguangyi @ Content ejb3 annotation of the API defined in the javax.persistence .* package inside. Note Note: @ Entity - a class declared as an entity bean (ie a persistent POJO class) @ Id - Note statement of the identity of the entity bea

  • android marker zoom with map 2010-10-25

    Martix by to set the picture in size. Question 1: How to save the picture after scaling? Question 2: how to google map to zoom to set the marker of the zoom level? With these two issues, we should look at how to do next in the

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.030 (s). 12 q(s)