Re: integer divided by zero

Liste des GroupesRevenir à cl c 
Sujet : Re: integer divided by zero
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.c
Date : 25. Apr 2025, 20:37:13
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vugo99$m2n2$2@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
Em 4/25/2025 2:50 PM, David Brown escreveu:
On 25/04/2025 19:38, Thiago Adams wrote:
Does 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.
>
 Some processors might give a specific value for their integer division instructions for divide by 0 - or they might support masking of relevant traps, exceptions or other fault mechanisms.  Software should probably not rely on division by 0 behaviour, even if it is in non-portable code.
 But most processors that are too small to have a fault, trap or exception system are also too small to have division instructions. There are exceptions, of course.
 Division by a constant 0 is not a constraint in C because that would require compilers to detect division by zero. 
This is easy for constant.
But conforming compilers
are free to detect it anyway, and issue a warning.  Note that compilers should probably not consider it a fatal error in the code (i.e., one that stops the compilation) unless the compiler can be sure that the code in question is not executed.  There is no problem having undefined behaviour in the code until you try to execute that code path.
 
Since 1/0 is not a constant, then if 1/0 were a constrain, the programmer could use a variable instead.
static int zero = 0;
1/zero //ok

Date Sujet#  Auteur
25 Apr 25 * integer divided by zero46Thiago Adams
25 Apr 25 +* Re: integer divided by zero6David Brown
25 Apr 25 i`* Re: integer divided by zero5Thiago Adams
25 Apr 25 i `* Re: integer divided by zero4Keith Thompson
26 Apr 25 i  `* Re: integer divided by zero3Thiago Adams
26 Apr 25 i   `* Re: integer divided by zero2Kenny McCormack
26 Apr 25 i    `- Re: integer divided by zero1Kaz Kylheku
25 Apr 25 +* Re: integer divided by zero9Keith Thompson
25 Apr 25 i+* Re: integer divided by zero6Thiago Adams
25 Apr 25 ii`* Re: integer divided by zero5Keith Thompson
25 Apr 25 ii +* Re: integer divided by zero3Kaz Kylheku
26 Apr 25 ii i`* Re: integer divided by zero2Keith Thompson
14 May 25 ii i `- Re: integer divided by zero1Tim Rentsch
28 Apr 25 ii `- Re: integer divided by zero1Thiago Adams
30 Apr 25 i`* Re: integer divided by zero2Rosario19
30 Apr 25 i `- Re: integer divided by zero1David Brown
25 Apr 25 +- Re: integer divided by zero1John McCue
26 Apr 25 +- Re: integer divided by zero1Waldek Hebisch
27 Apr 25 +* Re: integer divided by zero24Bonita Montero
27 Apr 25 i+* Re: integer divided by zero11Bonita Montero
27 Apr 25 ii`* Did you get confused again? You seem eaily bewildered. (Was: integer divided by zero)10Kenny McCormack
27 Apr 25 ii `* Re: Did you get confused again? You seem eaily bewildered. (Was: integer divided by zero)9Bonita Montero
27 Apr 25 ii  +* Re: Did you get confused again? You seem eaily bewildered. (Was: integer divided by zero)3Kaz Kylheku
27 Apr 25 ii  i+- Re: Did you get confused again? You seem eaily bewildered. (Was: integer divided by zero)1Bonita Montero
28 Apr 25 ii  i`- Re: Did you get confused again? You seem eaily bewildered.1Waldek Hebisch
28 Apr 25 ii  +* Re: Did you get confused again? You seem eaily bewildered.3Waldek Hebisch
30 Apr 25 ii  i+- Re: Did you get confused again? You seem eaily bewildered.1Rosario19
30 Apr 25 ii  i`- Re: Did you get confused again? You seem eaily bewildered.1Richard Heathfield
28 Apr 25 ii  `* Re: Did you get confused again? You seem eaily bewildered.2Waldek Hebisch
28 Apr 25 ii   `- Re: Did you get confused again? You seem eaily bewildered.1Bonita Montero
28 Apr 25 i+* Re: integer divided by zero4Richard Heathfield
28 Apr 25 ii`* Re: integer divided by zero3Bonita Montero
28 Apr 25 ii `* Re: integer divided by zero2Richard Heathfield
28 Apr 25 ii  `- Re: integer divided by zero1Bonita Montero
28 Apr 25 i`* Re: integer divided by zero8Richard Damon
28 Apr 25 i +* Re: integer divided by zero5Bonita Montero
28 Apr 25 i i+- Re: integer divided by zero1Bonita Montero
28 Apr 25 i i`* Re: integer divided by zero3Michael S
28 Apr 25 i i +- Re: integer divided by zero1Bonita Montero
28 Apr 25 i i `- Re: integer divided by zero1Muttley
28 Apr 25 i `* Re: integer divided by zero2Waldek Hebisch
28 Apr 25 i  `- Re: integer divided by zero1Bonita Montero
28 Apr 25 +* Re: integer divided by zero2Richard Heathfield
28 Apr 25 i`- Re: integer divided by zero1Keith Thompson
3 May 25 `* Re: integer divided by zero2Vir Campestris
3 May 25  `- Re: integer divided by zero1Michael S

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal