Newbie question. outputting float value as scientific notation

Hello all,

I am very new to Arduino programming. I apologize if this is terribly easy but ill cut straight to it.

I am reading an analog and applying a formula to it. The result will be in some value such as .00034 but I need it to read out to the OLED as 3.4^-4. The OLED screen and Formula I get but converting the float to scientific notation, I am lost. I have checked many resources online but they seem to be in some C type language which I know nothing of. My buddy helped me by writing some code but it either puts out 0.00 or inf.

Thank you for all your help in advance, losing my mind.

Google "dtostrf". That function will do what you want.

FRGVal = (pow(10, ((1.667 * ((analogRead(A7)/1024) * 20)) - 11.46)));
// FRGVal = (analogRead(A7) * .0048;
if (State == 5) {
display.setCursor(0, 0);
display.setCursor(0, 26);
char buffer[8];
display.println(dtostrf(FRGVal, 7, 6, buffer));

Can I please get additional help? I am trying to understand what I am doing wrong but cant figure it out. Here is the code, the rest of the code works except for outputting to Scientific notation. I am not sure what information you need to help me. OLED is I2C and I get a display value when using // line but only get zeros with other calculation. Thinking that the formula would be wrong, I forced to give crazy number where scientific notation would be needed, unfortunately only a big number appeared. Thanks again!

dtostrf() does not format numbers into scientific notation. See the function docs. Try dtostre() instead.

In principle, sprintf() will produce scientific notation using %e, and is FAR more flexible than the above functions, but that support is by default disabled on AVR based Arduinos and needs to be enabled to use.

If you want help with other questions, post ALL your code, using code tags.

Post actual examples of the output.

Please see the "How to use this forum" post for the details.