[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Make division by zero legal
From: |
Wolfgang Laun |
Subject: |
Re: Make division by zero legal |
Date: |
Sun, 1 Aug 2021 20:27:23 +0200 |
Programming languages are permitted to have their own rules regarding
arithmetic: integer and floating point. In many cases, the definition of
the IEEE standard regarding floating point arithmetic came after the
definition of the language. The more abstract concept of arithmetic in
awk's (and many other languages') definitions makes it undesirable to
continue program execution after a division by zero.
Which numeric algorithm would benefit from a continuation after an
intermediate result of infinity? Isn't it preferable to learn about a
problem in your program at the earliest possible moment?
Wolfgang
On Sun, 1 Aug 2021 at 19:24, Peng Yu <pengyu.ut@gmail.com> wrote:
> Hi,
>
> https://en.wikipedia.org/wiki/Division_by_zero
>
> The above page says.
>
> "The IEEE floating-point standard, supported by almost all modern
> floating-point units, specifies that every floating-point arithmetic
> operation, including division by zero, has a well-defined result. The
> standard supports signed zero, as well as infinity and NaN (not a
> number)."
>
> $ awk -e '{print 1/0 }'
> awk: cmd. line:1: error: division by zero attempted
>
> But awk does not treat the above division as legal. Should this be
> changed so that it gives less surprising results?
>
> In the meantime, what is the best walkaround to get awk conformed to
> the IEEE standard?
>
> --
> Regards,
> Peng
>
>
--
Wolfgang Laun
- Make division by zero legal, Peng Yu, 2021/08/01
- Re: Make division by zero legal,
Wolfgang Laun <=
- Re: Make division by zero legal, Nethox, 2021/08/02
- Re: Make division by zero legal, Andrew J. Schorr, 2021/08/02
- Re: Make division by zero legal, Neil R. Ormos, 2021/08/02
- Re: Make division by zero legal, Andrew J. Schorr, 2021/08/03
- Re: Make division by zero legal, Peng Yu, 2021/08/03
- Re: Make division by zero legal, Peng Yu, 2021/08/03
- Re: Make division by zero legal, Andrew J. Schorr, 2021/08/03