Dividing by zero should always throw an exception. If the numerator is also zero it returns zero instead. Sample Sketch to reproduce: #include "Arduino.h" //NodeMCU 0.9 ESP-12 Module long a; long b; long result; void setup() { Serial.begin(115200); delay (5000); a = 0; b = 0; result = a/b; Serial.print("Result1 = "); Serial.println(result); a = 1; Serial.print("Result2 = "); delay(5000); result = a/b; Serial.println(result); } void loop() { }