if I havearray[6] = {6,5,4,3,2,1};I want to have a double variable equal to "654321"
var = array[0] * 100000 + array[1] * 10000 + array[2] * 1000 + array[3] * 100 + array[4] * 10 + array[5];
void main(void) {
x1 = 3 * 10000;
x2 = 4 * 10000;x3 = 4 * 1000000;
x4 = 3000 + 12767;x5 = 3000 + 12768;}
Message Edited by Technoman64 on 04-07-200606:07 AM
Message Edited by Technoman64 on 04-07-200606:08 AM
thanks! The subroutine worked great. but the MyNumber variable didnt.
they look like they same operations too. for array[6] = {6,5,4,3,2,1};
number = 654321 which is great, but MyNumber = 601073.
also x4 and x4 were 15767 and 15768. Seems a little odd, but the subroutine works, so i'll work off that structure. thanks!
mark
sjmelnikoff wrote:If the six numbers are all single digits, you could convert them to an array of ASCII digits (by adding '0' to each one), then using the library function atof() (in stdlib.h) to convert the array directly to a float.
Forgot to mention that, if you do this, the last element of the array needs to contain zero (0, not '0'), indicating the end of the string.
Out of interest, where is your input data coming from? Is it a string to start with (as suggested by the title of the thread)?
Steve M.