[SOLVED] How to display precise floats on WiFi Kit 32?

Hello,

I am trying to display a float from an API, however, the default display is 2 decimal points i.e 0.00. I am trying to display a precise number of 4 decimal points (0.0000). For example, my code is listed below.

float duco_price = doc["Duco price"]; 

String DUCO_PRICE = "Price: " + (String)duco_price;

Heltec.display->drawString(40, 30, DUCO_PRICE);

I know the float displays a value up to 6 decimal points as I can view it on the Serial Monitor.

[SOLVED]

In order to draw the number of decimal placements you have to define it in another string. Example:

float duco_price = doc["Duco price"]; 
String duco_pricefix = String(duco_price, 6); //6 equals the number of decimals.

String DUCO_PRICE = "Price: " + (String)duco_price;

Heltec.display->drawString(40, 30, DUCO_PRICE);