Decimal point or comma

I am working with Processing 3.5.3 on a Mac with german system osx 10.11.6
When I say

float number = 0.2;
println(nf(number, 1, 2));

it prints

0,20
with decimal comma (common in everyday german life)
Is there a way to change this back?

1 Like

As you Dutch neighbour I encounter the same issue, believe it has to do with the default settings of our Operating System. Via your sketch you can adjust it by importing the Locale Class and setting the language settings to US:

import java.util.Locale;

void setup() {
  size(200, 200);
  noLoop();
  Locale.setDefault(Locale.US);
}

void draw() {
  float f = 9.012;
  String sf = nf(f, 3, 5);
  println(sf);
}

If you prefer that all your sketches use the dot automatically, other options to look into are:

  • change the language settings of your OS
  • tweak the language setting in the core files of Processing

Not sure the latter option works though.

4 Likes

Dear Neighbour!
It works.
Most of the time I need this printouts for control, but sometime I need them for another program.

Thanks a lot, Michael