Created
August 27, 2020 14:20
-
-
Save robertpainsi/726bde34d2ecd5504c1a88852cb94eeb 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
import java.math.BigDecimal; | |
public class CatrobatVersionNumberExceededTest { | |
public static void main(String[] args) { | |
int append = 1; | |
String base = "0."; | |
while (true) { | |
String versionAsText = base + append; | |
float version = Float.parseFloat(versionAsText); | |
// double version = Double.parseDouble(versionAsText); | |
BigDecimal real = new BigDecimal(versionAsText); | |
String trimmed = real.stripTrailingZeros().toPlainString(); | |
boolean equals = String.valueOf(version).compareTo(trimmed) == 0; | |
System.out.println(version + " " + versionAsText + " " + equals); | |
if (!equals) { | |
break; | |
} | |
append++; | |
if (append == 10) { | |
base += "9"; | |
append = 1; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output