retain two decimal digits.
2014-04-01 21:55
302 查看
package kju.o; import static kju.print.Printer.*; import java.text.*; class MathDemo { public static void main(String[] args) { double d = 1.2458; println(round(d)); //prints:1.25 } static String round(double d) { DecimalFormat nf = new DecimalFormat("#.00"); return nf.format(d); //retain two decimal digits. } }
相关文章推荐
- Two decimal places保留两位小数
- leetcode 21_Merge Two Sorted Lists & leetcode_258 Add Digits & leetcode_66plus one
- iOS Round Double value to 2 decimal digits and round 3rd decimal digit up
- C++ Ouput Exactly 2 Digits After Decimal Point 小数点后保留三位数字
- Given the array of digits (0 is also allowed), what is the minimal sum of two integers that are made
- Two-Phase Locking
- git get all different files between two revisions
- [Codeforces710D]Two Arithmetic Progressions(扩展中国剩余定理)
- Leetcode – Add Two Numbers (Java)
- LeetCode-Add Two Numbers
- Median of Two Sorted Arrays (第二周:分治法)
- LeetCode: Divide Two Integers
- [LeetCode]021-Merge Two Sorted Lists
- 371. Sum of Two Integers(C++)
- 关键字retain copy assign nonatomic property synthesize
- IOS atomic与nonatomic,assign,copy与retain的定义和区别
- [LeetCode]2 Add Two Numbers
- [leetcode] Add Two Numbers
- 40 For which two situations would you use functionality provided by the Resource Manager? (Choose tw
- GYM 100090 A. After Two Hares(水~)