Java Decimal From toDecimal(long val, int places)

Here you can find the source of toDecimal(long val, int places)

Description

to Decimal

License

Open Source License

Declaration

public static String toDecimal(long val, int places) 

Method Source Code

//package com.java2s;

public class Main {
    public static String toDecimal(long val, int places) {
        StringBuffer buf = new StringBuffer(10 + places);
        while (places > 0) {
            buf.append(val % 10);
            places--;//from   w  w  w.  ja  va  2  s  .  c o m
            val = val / 10;
            if (places == 0)
                buf.append('.');
        }
        buf.reverse();
        return val + buf.toString();

    }
}

Related

  1. toDecimal(final String intValue)
  2. toDecimal(float value)
  3. toDecimal(int value, byte[] buffer, int offset, int length, int itemLength, boolean packed)
  4. toDecimal(String coord)
  5. toDecimal(String number)