1 | public static String formatDouble(double d, int digits) {
|
2 | String format = "0."; |
3 | for (int i = 0; i < digits; i++) format += "#"; |
4 | return new java.text.DecimalFormat(format, new java.text.DecimalFormatSymbols(Locale.ENGLISH)).format(d); |
5 | } |
Snippet is not live.
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #2000510 |
| Snippet name: | formatDouble |
| Eternal ID of this version: | #2000510/1 |
| Text MD5: | 04683d1e74165eae6118df512c5eeb9e |
| Author: | stefan |
| Category: | javax |
| Type: | New Tinybrain snippet |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-08-10 13:40:52 |
| Source code size: | 257 bytes / 5 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 946 / 835 |
| Referenced in: | [show references] |