Problem with Mathmetical operation on I2C output of HMC5883l Magnetometer

Hi everyone:-\ :-\ :-\ :-\ :-\
I’m trying to read and measure the Total Magnetic field (flux) by using an HMC5883 Mag Sensor.
after weeks I found the following code to read the X, Y, and Z values. but the problem is here on converting the Raw values to Gause or nTessla and but the IDE does not calculate even a Multiplication by 10 correctly especially when the raw values go above ±4000?

=== The Code:
#include <Wire.h>
#include <MechaQMC5883.h>

MechaQMC5883 qmc;

void setup() {
Wire.begin();
Serial.begin(115200);
Serial.println(“Initializing I2C devices…”);
qmc.init();
// verify connection

qmc.setMode(Mode_Continuous, ODR_200Hz, RNG_2G, OSR_256);
}

void loop() {
int x, y, z;
qmc.read(&x, &y, &z);
long signed int X = x;
long signed int Y = y;
long signed int Z = z;
long signed int Xs = ((abs(x)) * 10);
long signed int Ys = ((abs(y)) * 10);
long signed int Zs = ((abs(z)) * 10);
long signed int Xx = (Xs * Xs);
long signed int Yy = (Ys * Ys);
long signed int Zz = (Zs * Zs);
long signed int XYZ = (Xx + Yy + Zz);
long signed int T = sqrt(XYZ);
Serial.print("[ ");
Serial.print("x: “);
Serial.print(x);
Serial.print(” y: “);
Serial.print(y);
Serial.print(” z: “);
Serial.print(z);
Serial.print(”][ ");
Serial.print("X: “);
Serial.print(X);
Serial.print(” Y: “);
Serial.print(Y);
Serial.print(” Z: “);
Serial.print(Z);
Serial.print(”][ ");
Serial.print("Xs: “);
Serial.print(Xs);
Serial.print(” Ys: “);
Serial.print(Ys);
Serial.print(” Zs: “);
Serial.print(Zs);
Serial.print(” ] “);
Serial.print(” Xx: “);
Serial.print(Xx);
Serial.print(” XYZ: “);
Serial.print(XYZ);
Serial.print(” T: ");
Serial.print(T);
Serial.println();
delay(1000);
}

and
====== The Serial Output:

[ x: -4272 y: -747 z: 3602][ X: -4272 Y: -747 Z: 3602][ Xs: -22816 Ys: 7470 Zs: -29516 ] Xx: 520569856 XYZ: 1447565012 T: 38046
[ x: -4240 y: -837 z: 3650][ X: -4240 Y: -837 Z: 3650][ Xs: -23136 Ys: 8370 Zs: -29036 ] Xx: 535274496 XYZ: 1448420692 T: 38058
[ x: -4217 y: -737 z: 3617][ X: -4217 Y: -737 Z: 3617][ Xs: -23366 Ys: 7370 Zs: -29366 ] Xx: 545969956 XYZ: 1462648812 T: 38244
[ x: -4207 y: -785 z: 3617][ X: -4207 Y: -785 Z: 3617][ Xs: -23466 Ys: 7850 Zs: -29366 ] Xx: 550653156 XYZ: 1474637612 T: 38401
[ x: -4222 y: -757 z: 3637][ X: -4222 Y: -757 Z: 3637][ Xs: -23316 Ys: 7570 Zs: -29166 ] Xx: 543635856 XYZ: 1451596312 T: 38099
[ x: -4207 y: -832 z: 3582][ X: -4207 Y: -832 Z: 3582][ Xs: -23466 Ys: 8320 Zs: -29716 ] Xx: 550653156 XYZ: 1502916212 T: 38767
[ x: -4207 y: -800 z: 3655][ X: -4207 Y: -800 Z: 3655][ Xs: -23466 Ys: 8000 Zs: -28986 ] Xx: 550653156 XYZ: 1454841352 T: 38142
[ x: -4240 y: -850 z: 3602][ X: -4240 Y: -850 Z: 3602][ Xs: -23136 Ys: 8500 Zs: -29516 ] Xx: 535274496 XYZ: 1478718752 T: 38454
[ x: -4162 y: -770 z: 3575][ X: -4162 Y: -770 Z: 3575][ Xs: -23916 Ys: 7700 Zs: -29786 ] Xx: 571975056 XYZ: 1518470852 T: 38967
[ x: -4185 y: -790 z: 3617][ X: -4185 Y: -790 Z: 3617][ Xs: -23686 Ys: 7900 Zs: -29366 ] Xx: 561026596 XYZ: 1485798552 T: 38546
[ x: -4175 y: -780 z: 3602][ X: -4175 Y: -780 Z: 3602][ Xs: -23786 Ys: 7800 Zs: -29516 ] Xx: 565773796 XYZ: 1497808052 T: 38701
[ x: -4195 y: -780 z: 3575][ X: -4195 Y: -780 Z: 3575][ Xs: -23586 Ys: 7800 Zs: -29786 ] Xx: 556299396 XYZ: 1504345192 T: 38785
[ x: -4142 y: -780 z: 3607][ X: -4142 Y: -780 Z: 3607][ Xs: -24116 Ys: 7800 Zs: -29466 ] Xx: 581581456 XYZ: 1510666612 T: 38867
[ x: -4175 y: -800 z: 3550][ X: -4175 Y: -800 Z: 3550][ Xs: -23786 Ys: 8000 Zs: -30036 ] Xx: 565773796 XYZ: 1531935092 T: 39139
[ x: -4130 y: -807 z: 3670][ X: -4130 Y: -807 Z: 3670][ Xs: -24236 Ys: 8070 Zs: -28836 ] Xx: 587383696 XYZ: 1484023492 T: 38523

Please use code tags when posting code.

the IDE does not calculate even a Multiplication by 10 correctly especially when the raw values go above +-4000?

Expressions to the right of "=" default to 16 bit ints and you get numerical overflow.

 long signed int Xs = ((abs(x)) * 10);
  long signed int Ys = ((abs(y)) * 10);
  long signed int Zs = ((abs(z)) * 10);
  long signed int Xx = (Xs * Xs);
  long signed int Yy = (Ys * Ys);
  long signed int Zz = (Zs * Zs);
  long signed int XYZ = (Xx + Yy + Zz);
  long signed int T = sqrt(XYZ);

Fixed as follows. What does the "10" above do for you ?

  long signed int Xx = x;
  long signed int Yy = y;
  long signed int Zz = z;
  long signed int XYZ = (Xx*Xx + Yy*Yy + Zz*Zz);
  long signed int T = 10*sqrt(XYZ);