I have a few seven segment leds and I want the temperature ic float displayed. The code is set up so an integer is assigned to each digit.
(working test code)
int a=1;
int b=2;
int c=3;
write_digits(a,b,c);
Is there an easy way to have a float to array? Then my temperature ic could do something like:
float temperature = getTemp(); somehow put the float into an array
write_digits(temp[0],temp[1],temp[2],temp[3]);
Although, since you know the precision you want, you could just multiply it by 10^n, where n is how many digits you want, assign it to an int, and send it through atoi().
c=temperature % 10; temperature / = 10;
b=temperature % 10; temperature / = 10;
a=temperature % 10;
For that to be fast and accurate, you want temperature to be an integer.
So here is the irony of your proposal: you want to convert an integer into float, only to have to convert it back to integer so you can do what you are trying to do.
It works! Thanks to all for the help. I'm trying to figure it now since I stick to hardware design and rarely write code. I have no idea what the line t /= 10; is yet but i'll figure it out. I think I have the rest of it in my head.