This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into 1.7.10-shortening
Conflicts: src/main/java/com/kamesuta/mc/signpic/entry/content/ContentManager.java
- Loading branch information
Showing
11 changed files
with
78 additions
and
80 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/com/kamesuta/mc/bnnwidget/ShortestFloatFormatter.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.kamesuta.mc.bnnwidget; | ||
|
||
import java.text.DecimalFormat; | ||
import java.text.DecimalFormatSymbols; | ||
|
||
public class ShortestFloatFormatter { | ||
private static final DecimalFormat signformat; | ||
|
||
static { | ||
final DecimalFormat format = new DecimalFormat(".##"); | ||
final DecimalFormatSymbols custom = new DecimalFormatSymbols(); | ||
custom.setDecimalSeparator('.'); | ||
format.setDecimalFormatSymbols(custom); | ||
signformat = format; | ||
} | ||
|
||
public static String format(final float f) { | ||
if (f==0) | ||
return "0"; | ||
|
||
final String str = signformat.format(f); | ||
|
||
final String cut = ".0"; | ||
|
||
int end = str.length(); | ||
int last = cut.length(); | ||
|
||
while (end!=0&&last!=0) | ||
if (cut.charAt(last-1)==str.charAt(end-1)) | ||
end--; | ||
else | ||
last--; | ||
return str.substring(0, end); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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