spilt a number and Store it in an array

hey everyone, i want to get a file size then send it to another Arduino

the only way i can think of it now is to store it in array then send it

i wrote the following code

  tSize = 99876;
         Serial.println(tSize);
     for (int j = 0; j <8; j++) {
     
    size_of_data[j] = tSize % 10;
     tSize /= 10;
    delay(500);
    Serial.print("index ");
    Serial.println(j);
    Serial.println(size_of_data[j]);
}
byte x[8];
double num = 0 ; 
for (int w = 0 ; w<8 ; w++){
  Serial.print("revers ");
   Serial.println(w);
  num+= size_of_data[w] * pow(10,w);
  Serial.println(num);
  delay(500);
}
Serial.println(num);

the result

21:35:33.460 -> 99876
21:35:33.967 -> index 0
21:35:33.967 -> 6
21:35:34.463 -> index 1
21:35:34.463 -> 7
21:35:34.972 -> index 2
21:35:34.972 -> 8
21:35:35.471 -> index 3
21:35:35.471 -> 9
21:35:35.978 -> index 4
21:35:35.978 -> 9
21:35:36.487 -> index 5
21:35:36.487 -> 0
21:35:36.954 -> index 6
21:35:36.990 -> 0
21:35:37.477 -> index 7
21:35:37.477 -> 0
21:35:37.477 -> revers 0
21:35:37.510 -> 6.00
21:35:37.986 -> revers 1
21:35:37.986 -> 76.00
21:35:38.486 -> revers 2
21:35:38.486 -> 876.00
21:35:38.976 -> revers 3
21:35:38.976 -> 9876.00
21:35:39.475 -> revers 4
21:35:39.475 -> 99875.99
21:35:39.970 -> revers 5
21:35:39.970 -> 99875.99
21:35:40.473 -> revers 6
21:35:40.473 -> 99875.99
21:35:40.984 -> revers 7
21:35:40.984 -> 99875.99
21:35:41.500 -> 99875.99

it just give like this how to solve it ?

for arduino double is a float, but you dont need float. Use unsigned long instead

khalidd7:
hey everyone, i want to get a file size then send it to another Arduino

.....

it just give like this how to solve it ?

Have a look at @Robin's Thread Serial Input Basics - simple reliable ways to receive data.

in a nutshell, as an example, for the sender side side:

tSize = 99876;
Serial.write('F'); //example for a starter marker for to indicate sending filesize
Serial.println(tSize); //you can use the carriage return character as you end marker! :slight_smile: