Skip to content

Divide by Zero does not fail when numerator is Zero #7495

Closed
@JMWilton

Description

@JMWilton

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()
{

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions