usigned int to int

Below I tried to convert a int to byte, store it in EEPROM and then read back the int out.

However, I could only obtain an unsigned integer from the storage. My number would be max. 60,000, no negative numbers.

Note that result gives correct result while result2 does not...... Thanks!

void Intobyte(int i, int add1, int add2) {
byte * b = (byte *) &i;
EEPROM.write(add1, b[0]);
EEPROM.write(add2, b[1]);
}

void BytetoInt(byte b1, byte b2){
unsigned int result = (int)word(b2, b1);
int result2 = (int)(result);
Serial.println(result);
Serial.println(result2);
}

if you want to convert int to unsigned int here is an example

#include<stdio.h>
int main()
{
	int i = -90;
	int j = -1;
	printf("%u\n%u", (unsigned int)i, (unsigned int)j);
	
	return 0;
}
  unsigned int result = (int)word(b2, b1);

Casting the unsigned int that word() returns to an int makes NO sense.

  int result2 = (int)(result);

Casting the unsigned int, which can hold a value between 0 and 65535 to an int, which can hold -32768 to +32767, makes no sense when your values between 0 and 60000.

Why are you thinking you can use ints to hold values in the range 0 to 60000 when you KNOW that that is the range of an unsigned int?