And yet again for expr :-).
$ expr -2147483648 / -1
Floating point exception (core dumped)
expr on Linux (GNU or whatever it is) reports "Numerical result out of
range" for this. But it does the same for other overflows (such as "expr
-9223372036854775808 - 1" on a 64-bit platform) where we just
On Wed, Mar 27, 2013 at 04:27:22PM -0700, Matthew Dempsky wrote:
> On Wed, Mar 27, 2013 at 4:15 PM, Nicholas Marriott
> wrote:
> > Sure, that actually looks to be what other shells do anyhow.
>
> That looks ok to me.
>
> Which shells did you check, out of curiosity? On Goobuntu, both bash
> and
On Wed, Mar 27, 2013 at 4:15 PM, Nicholas Marriott
wrote:
> Sure, that actually looks to be what other shells do anyhow.
That looks ok to me.
Which shells did you check, out of curiosity? On Goobuntu, both bash
and dash give SIGFPE too actually.
Checking POSIX, I notice that it requires that s
And the same for csh (@ x = -2147483648 % -1):
Index: exp.c
===
RCS file: /cvs/src/bin/csh/exp.c,v
retrieving revision 1.9
diff -u -p -r1.9 exp.c
--- exp.c 20 Jul 2010 02:13:10 - 1.9
+++ exp.c 27 Mar 2013 23:23:48
Sure, that actually looks to be what other shells do anyhow.
Index: expr.c
===
RCS file: /cvs/src/bin/ksh/expr.c,v
retrieving revision 1.21
diff -u -p -r1.21 expr.c
--- expr.c 1 Jun 2009 19:00:57 - 1.21
+++ expr.c
On Wed, Mar 27, 2013 at 3:56 PM, Nicholas Marriott
wrote:
> case O_DIV:
> case O_DIVASN:
> + if (vl->val.i == LONG_MIN && vr->val.i == -1)
> + evalerr(es, ET_STR, "can't represent result");
>
Hi
On i386:
$ ksh -c 'echo $((-2147483648 / -1))'
Floating point exception (core dumped)
$ ksh -c 'echo $((-2147483648 % -1))'
Floating point exception (core dumped)
Was the same at least on amd64 with LONG_MIN last I could check.
Perhaps something like this?
Index: expr.c
===