Sujet : Re: integer divided by zero
De : rjh (at) *nospam* cpax.org.uk (Richard Heathfield)
Groupes : comp.lang.cDate : 28. Apr 2025, 14:52:17
Autres entêtes
Organisation : Fix this later
Message-ID : <vuo16h$3d25d$4@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
On 25/04/2025 18: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.
C? I doubt it very much.
In the 1980s, there was a BASIC dialect for 68000s, called GFA BASIC, which was available as both an interpreter and a compiler. The interpreter produced an error for 0/0, but the compiler optimised it to 1 (on the grounds that, for any a, a/a=1).
-- Richard HeathfieldEmail: rjh at cpax dot org dot uk"Usenet is a strange place" - dmr 29 July 1999Sig line 4 vacant - apply within