Created
November 3, 2013 23:53
-
-
Save stephenh/7296159 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package temp; | |
| import java.math.BigDecimal; | |
| import java.math.BigInteger; | |
| public class Test { | |
| public static void main(String[] args) { | |
| System.out.println(toSeventeenDigits(1000)); | |
| System.out.println(toSeventeenDigits(100)); | |
| System.out.println(toSeventeenDigits(10)); | |
| System.out.println(toSeventeenDigits(1)); | |
| } | |
| private static String toSeventeenDigits(long l) { | |
| BigDecimal d = new BigDecimal(BigInteger.valueOf(l), 17); | |
| d = d.divide(new BigDecimal(10).pow(17)); | |
| return d.toPlainString(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 0.0000000000000000000000000000001 | |
| 0.00000000000000000000000000000001 | |
| 0.000000000000000000000000000000001 | |
| 0.0000000000000000000000000000000001 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment