Liste des Groupes | Revenir à cl c |
On Fri, 25 Apr 2025 12:05:13 -0700, Keith Thompson wrote:In common mathematics, 1 / 0 is undefined - just like in C. If you extend the set of real numbers to include some kind of infinity ∞ , you immediately lose many other useful properties of the set. INT_MAX is not a good approximation - there is no int value that makes sense for the result of 1 / 0.
Thiago Adams writes:in mathDoes anyone know of any platform where integer division by zero>
returns a number, or in other words, where it's not treated as an
error? I'm asking because division by zero is undefined behaviour, but
I think division by a constant zero should be a constraint instead.
Division by a constant zero is a constraint violation in a context that
requires a constant expression.
>
I wrote this quick and dirty program:
>
#include <stdio.h>
#include <time.h>
int main(void) {
int one = time(NULL) / 1000000000;
int zero = one - 1;
int ratio = one / zero;
printf("%d\n", ratio);
1/0 has to be +infinite ( for approximation +INT_MAX for C?)
Les messages affichés proviennent d'usenet.