Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Active reading.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

Naw, never mind.

Performance The performance loss due to Stringstring manipulation is zero.

And here's the code to trim the end after %f:

private static String trimTrailingZeros(String number) { if(!number.contains(".")) { return number; }   return number.replaceAll("\\.?0*$", ""); } 

Naw, never mind.

Performance loss due to String manipulation is zero.

And here's the code to trim the end after %f

private static String trimTrailingZeros(String number) { if(!number.contains(".")) { return number; }   return number.replaceAll("\\.?0*$", ""); } 

Naw, never mind. The performance loss due to string manipulation is zero.

And here's the code to trim the end after %f:

private static String trimTrailingZeros(String number) { if(!number.contains(".")) { return number; } return number.replaceAll("\\.?0*$", ""); } 
added 2 characters in body
Source Link
Pyrolistical
  • 28.1k
  • 21
  • 86
  • 109

Naw, never mind.

Performance loss due to String manipulation is zero.

And here's the code to trim the end after %f

private static String trimTrailingZeros(String number) { if(!number.contains(".")) { return number; } return number.replaceAll(""\\.?0*$", ""); } 

Naw, never mind.

Performance loss due to String manipulation is zero.

And here's the code to trim the end after %f

private static String trimTrailingZeros(String number) { if(!number.contains(".")) { return number; } return number.replaceAll(".?0*$", ""); } 

Naw, never mind.

Performance loss due to String manipulation is zero.

And here's the code to trim the end after %f

private static String trimTrailingZeros(String number) { if(!number.contains(".")) { return number; } return number.replaceAll("\\.?0*$", ""); } 
Used Rehno's suggestion
Source Link
Pyrolistical
  • 28.1k
  • 21
  • 86
  • 109

Naw, never mind.

Performance loss due to String manipulation is zero.

And here's the code to trim the end after %f

private static String trimTrailingZeros(String number) { if(!number.contains(".")) { return number; } number =return number.replaceAll("0*$", ""); if(number.charAt(number.length() - 1) == '.') { number = number".substring(0?0*$", number.length() - 1""); } return number; } 

Naw, never mind.

Performance loss due to String manipulation is zero.

And here's the code to trim the end after %f

private static String trimTrailingZeros(String number) { if(!number.contains(".")) { return number; } number = number.replaceAll("0*$", ""); if(number.charAt(number.length() - 1) == '.') { number = number.substring(0, number.length() - 1); } return number; } 

Naw, never mind.

Performance loss due to String manipulation is zero.

And here's the code to trim the end after %f

private static String trimTrailingZeros(String number) { if(!number.contains(".")) { return number; } return number.replaceAll(".?0*$", ""); } 
added 42 characters in body
Source Link
Pyrolistical
  • 28.1k
  • 21
  • 86
  • 109
Loading
Source Link
Pyrolistical
  • 28.1k
  • 21
  • 86
  • 109
Loading