A datatype in C/C++ which stores a single-precision floating point number.
Questions tagged [float]
83 questions
17
votes
1 answer
How do I convert a float into char*?
Asked this question on Electrical Engineering Stack Exchange and was directed here:
Pretty self explanatory; how would I go about converting a float into a char*? I have code in which the float 'resistance' is constantly being updated. I would like…
higgsboson
- 173
- 2
- 2
- 6
10
votes
2 answers
Is there a non-float alternative to pow()?
I've scoured the LANGUAGE REFERENCE in the Arduino web-site, and I can't find a non-Float equivalent to pow() I've got to be missing something big, but for the life of me, I'm stumped! I found pow() in the FUNCTIONS column under the Math heading…
user16841
9
votes
3 answers
Only 2 decimal places in printed float
There was a similar thread before but it didn't solve my problem. I had an issue with sending GPS data, which is float, and I couldn't receive the float with the same amount of significant figures as I was sending. I always received a number with 2…
Anthropomorphous Dodecahedron
- 233
- 1
- 3
- 8
7
votes
3 answers
Sending and receiving different types of data via I2C in Arduino
I have found a few good tutorials on how to send and receive data via I2C in connected arduinos. My limitation is now how to transmit different types of data like for instance, long, float, etc. Right now the communication via I2C using the wire…
Camilo
- 359
- 2
- 5
- 12
5
votes
1 answer
Serial monitor can't display float and double values with absolute greater than 4294967040=2^32-2^8
I have the following sketch:
void setup() {}
void loop() {
float af = 4294967040.0;
float bf = 4294967240.0;
double ad = 4294967040.0;
double bd = 4294967040.00001;
Serial.println(af);
Serial.println(bf);
Serial.println(ad);
…
LukasFun
- 295
- 1
- 4
- 17
5
votes
4 answers
Will an ATmega2560 board be faster than a Uno for hard real-time data logging?
I am designing a hard real-time data logger. The Uno is a bit marginal in processing speed.
a) Would it be faster if I changed to an ATmega2560?
b) On the datasheet, ATMEGA2560 has 135 instructions; it is 4 instructions more than the…
EEd
- 904
- 1
- 14
- 21
5
votes
6 answers
When is it necessary to use "float" instead of "int"?
I'm very new to Arduino and I am making a code for a pedometer. I have a lot of variables and I have used "int" multiple times, but I just came across a code with "float".
Now because my coding background is next to none, I don't really understand…
user30763
- 61
- 2
- 2
- 4
5
votes
1 answer
How to append float value of into a string ?
I have a float variable lng = 33.785469 and lat = 78.126548. Now can I convert them to String and append in a String variable "my_location" as "your location is \nlng = 33.785469 \nlat = 78.126548". I was trying to do this with
char charVal[5];…
Anum Sheraz
- 191
- 1
- 5
- 11
5
votes
2 answers
Store floats in and reading them from flash
How do I store floats in flash and how do I read them from there? (I need a look-up table for pairs of float values.)
The storing part doesn't seem to be so difficult as this compiles:
PROGMEM float value1 = 1.23456;
But how do I read them? Do I…
fuenfundachtzig
- 1,535
- 1
- 14
- 26
3
votes
4 answers
String to float on Arduino
I'm trying to convert a String to a float but I'm running into issues with precision, even with the Arduino's own String example I'm getting bad results.
Example 0:
Input string: 1.234567 After conversion to float: 1.2345669
Example 1:
Input…
user3635319
- 43
- 1
- 4
3
votes
2 answers
Floating-point without FPU
Since a Floating Point Unit (FPU) is not present in Arduino Uno, I wanted to know how float operations are performed. If it is simulated as integer operations, I want to know how exactly the simulation is done.
Sridhar Gopinath
- 31
- 1
- 3
3
votes
2 answers
Avoiding float math to speed up arduino
I read and heard that the floating point math is much slower than int math.
And I saw a converting process in here floath math to integer math
So I want to to convert my floating math calculations to integer math.
Here is the code that include…
sir mordred
- 55
- 1
- 5
2
votes
1 answer
Enable full float-capable snprintf() library with PlatformIO
I want to use snprintf() to format floats to a string.
I know the "normal" version of Arduino's avrlibc had all the float-formatting code removed to make it smaller.
I also know that at some point in the fairly recent past, it became possible to…
Bitbang3r
- 561
- 1
- 3
- 14
2
votes
1 answer
Read data from SD
I have logged some data in my sdcard/FAT32 (format).
I can read and display them on the serial monitor but additionally I want to use these data as float.
Here is my code:
byte index = 0;
Tfile = SD.open("DATALOG.TXT",FILE_READ);
…
G.V.
- 137
- 1
- 4
2
votes
1 answer
Convert float to byte, from Arduino to Raspberry Pi i2c
I'm trying to send the temperature value from the DHT sensor to a raspberry pi through I2C.
Which is the best way to do it?. The temp value is a float, and I think I have to convert it to byte and send that with Wire.write() to the raspberry, is…
Guille
- 123
- 3