float to string conversion broken?

I tried the following program

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  Serial.println("Test Ser Out");


  String test = String(5.02131234, 4);

  Serial.println(test);
}

void loop() {
  // put your main code here, to run repeatedly:
}

I get the following output

Test Ser Out
%6.4f

Any ideas

known issue. see https://github.com/sparkfun/Arduino_Apollo3/issues/278

Thanks, I see that after posting.

However, I do need to fix it, are there any precompiled mbed os files that can be used in place of the default one, or is there a detailed explanation how to resolve this using a windows (not linux) system.

I would rather avoid having to use a custom ftoa subroutine to do this.

Unfortunately as well, the project is very time limited, and this needs to be resolved over the next 24-48h.

Thanks

There has not been an updated pre-compiled boards library.

You can use the same steps as I posted there on 7 april.

Unzip and make the 2 changes in HardwareSerial.cpp in the directory location: \AppData\Local\Arduino15\packages\Sparkfun\hardware\apollo3\2.2.1\cores\arduino\mbed-bridge\core-implement

I did that, but it did not work. The program compiled ok, but the floats still only print the format string, and not the actual number.

I was not sure if that was for the padded strings, or if enables the standard printf.

I also tried adding an mbed_app.json file in my root, but I don’t think that would work without an mbed recompile.

Let me know if the changes listed should work for enabling all std printd features, and maybe I did something wrong?

you are right. The approach in the post is only changing/correcting a “serial.printf()”, not a sprintf(). need to take a bit more time to look into that.

Ib can verify that serial.print(float var), does print correctly, not

sprint, or

Float various =:String(float,decpts)

You can always use dtostrf() to convert floats to C-strings (similar to the way you were trying to use sprintf()).

https://www.hobbytronics.co.uk/arduino-float-vars

I used an ftoa function off the net for now (while hopefully a variant mbed OS is compiled with the full printf enabled). However, your suggestion would have made a good temporary replacement as well.

Thanks