| ??? 08/07/07 22:04 Read: times |
#142908 - array not float? Responding to: ???'s previous message |
Thanks for the suggestion Jan, I found sample code that worked well for me, the only problem is with float numbers in the array are not recognized as float.
If I comple and run following:
#include<reg52.h>
#include<stdio.h>
void InitSerial(void);
float getHighest(unsigned char, int size);
//---------------------------------------
// Main program
//---------------------------------------
void main(void)
{
InitSerial(); // Initialize serial port
while(1)
{
unsigned char temp_array[3]={10.5, 40.5, 30.6};
printf("%5.2f \n",getHighest(temp_array,3) );
}
}
//---------------------------------------
// Initialize serial port
//---------------------------------------
void InitSerial(void)
{
SCON = 0x52; // setup serial port control
TMOD = 0x20; // hardware (9600 BAUD @11.05592MHZ)
TH1 = 0xFD; // TH1
TR1 = 1; // Timer 1 on
}
float getHighest(unsigned char array[], int size)
{
float highest;
int count;
highest = array[0];
for (count = 1; count < size; count++)
{
if (array[count] > highest)
highest = array[count];
}
return highest;
}
Instead of 40.5 I'm getting only 40.00, how do I delcare temp_array[] properly? |
| Topic | Author | Date |
| help required with array manipulation in c# | 01/01/70 00:00 | |
| just having formatted | 01/01/70 00:00 | |
| array not float? | 01/01/70 00:00 | |
| Try This | 01/01/70 00:00 | |
| but be sure to comment it carefully! | 01/01/70 00:00 | |
| Why do you keep saying C# ?? | 01/01/70 00:00 | |
| Two things that are definitly wrong | 01/01/70 00:00 | |
| Two things wrong with thing 1 | 01/01/70 00:00 | |
| Sorry and Thanks | 01/01/70 00:00 | |
| Also.. | 01/01/70 00:00 | |
| ...and, 8051 specifically | 01/01/70 00:00 | |
| 8051 in C programming | 01/01/70 00:00 | |
first and second | 01/01/70 00:00 |



