// Forum: https://forum.arduino.cc/t/swap-two-integers-without-using-a-temporary-variable/1285996
// This Wokwi project: https://wokwi.com/projects/404992906749892609
void setup()
{
Serial.begin(115200);
// Start values
float A = 1E-8;
float B = 1E8;
// Print start values
Serial.print("A = ");
Serial.print(A,8);
Serial.print(", B = ");
Serial.println(B,8);
// Swap using the floating point library
B = B - A;
A = A + B;
B = A - B;
// Print end values
Serial.print("A = ");
Serial.print(A,8);
Serial.print(", B = ");
Serial.println(B,8);
}
void loop() {}