# Newbie question.  outputting float value as scientific notation

**URL:** <https://forum.arduino.cc/t/newbie-question-outputting-float-value-as-scientific-notation/601813>\
**Category:** Programming\
**Created:** [July 15, 2019, 10:00pm UTC](https://forum.arduino.cc/t/newbie-question-outputting-float-value-as-scientific-notation/601813 "2019-07-15T22:00:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mosca8](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@Mosca8](https://forum.arduino.cc/u/Mosca8)\
**Post date:** [July 15, 2019, 10:00pm UTC](https://forum.arduino.cc/t/newbie-question-outputting-float-value-as-scientific-notation/601813/1 "2019-07-15T22:00:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mosca8](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@Mosca8](https://forum.arduino.cc/u/Mosca8)\
**Post date:** [July 16, 2019, 12:09am UTC](https://forum.arduino.cc/t/newbie-question-outputting-float-value-as-scientific-notation/601813/3 "2019-07-16T00:09:11Z")

</div>

FRGVal = (pow(10, ((1.667 \* ((analogRead(A7)/1024) \* 20)) - 11.46)));  
// FRGVal = (analogRead(A7) \* .0048;  
if (State == 5) {  
display.setTextSize(1);  
display.setTextColor(WHITE);  
display.setCursor(0, 0);  
display.println("FROG");  
display.display();  
display.setTextSize(1);  
display.setTextColor(WHITE);  
display.setCursor(0, 26);  
display.display();  
display.clearDisplay();  
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!

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [July 16, 2019, 12:24am UTC](https://forum.arduino.cc/t/newbie-question-outputting-float-value-as-scientific-notation/601813/4 "2019-07-16T00:24:36Z")

</div>

dtostrf() does not format numbers into scientific notation. See [the function docs](https://www.microchip.com/webdoc/AVRLibcReferenceManual/group __avr__ stdlib_1ga060c998e77fb5fc0d3168b3ce8771d42.html). Try [dtostre()](https://www.microchip.com/webdoc/AVRLibcReferenceManual/group __avr__ stdlib_1ga6c140bdd3b9bd740a1490137317caa44.html) 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.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 11:56pm UTC](https://forum.arduino.cc/t/newbie-question-outputting-float-value-as-scientific-notation/601813/5 "2021-05-05T23:56:01Z")

</div>

Closed on May 5, 2021, 11:56pm UTC


