Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
public class Zahlen {
public static void main(String[] args) throws ParseException {
DecimalFormat nf = (DecimalFormat) NumberFormat.getNumberInstance(Locale.GERMAN);
nf.setParseBigDecimal(true);
String wert = "1.484,10";
System.out.println(nf.parse(wert));
}
}
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
public class Zahlen {
public static void main(String[] args) throws ParseException {
DecimalFormat nf = (DecimalFormat) NumberFormat.getNumberInstance(Locale.GERMAN);
nf.setParseBigDecimal(true);
String wert = "1.484,10";
System.out.println(nf.parse(wert));
}
}
float/double komplett ungeeignet ist fuer Waehrungen und Geld. Aufgrund der Rundungsfehler bei Gleitkommazahlen kommt dabei einfach nur noch Murks heraus.BigDecimal, das hat eine arbitraere Genauigkeit und damit keine Rundungsfehler. ... Ich glaube dafuer muss ich mal eine Wiederholung schreiben auf die ich verweisen kann.nf.setParseBigDecimal(true); gedacht. 🙂