0

I have the number '19,476.86' in a text file and I would like to use it to perform math operations such as addition, subtraction, multiplication, how do I do it?

        String s = "19.476,90";
        DecimalFormat  formateador = new DecimalFormat ("#.00");
        Number resultado = formateador.parse(s);
        System.out.println("Resultado: " + resultado);

Output:

Resultado: 19.476

I want to use the full number and not have the ',80' left out

imnach2
  • 13
  • 4
  • 1
    Could it be because you have your decimal point and comma switched around? – Calvin P. Feb 24 '23 at 16:25
  • 1
    "I have the number '19,476.86' in a text file" - that's not what your code shows. What's *actually* in the file? – Jon Skeet Feb 24 '23 at 16:28
  • @JonSkeet about the txt file is a simply string what have that number – imnach2 Feb 24 '23 at 17:56
  • @CalvinP. i from Argentina... – imnach2 Feb 24 '23 at 17:56
  • I don't understand your comment. Is the content of the text file "19,476.86" or "19.476,90"? You've described one, and then given a different one in your source code. It's very hard to help with contradictory requirements. (And chances are the duplicate actually contains the answer...) – Jon Skeet Feb 24 '23 at 18:14

0 Answers0