Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: prevent SIGFPE on systems where LONG_MIN < -LONG_MAX



On Mon, 3 Sep 2012 16:40:37 +0200
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> See also this thread,
> http://www.zsh.org/mla/workers/2011/msg00613.html
> 
> On 03/09/2012, Jérémie Roquet <arkanosis@xxxxxxxxx> wrote:
> > Hello,
> >
> > $ echo $[ - 2**63 / -1 ]
> > zsh: floating point exception  ./Src/zsh
> >
> > $ echo $[ - 2**63 % -1 ]
> > zsh: floating point exception  ./Src/zsh
> >
> > The attached patch fixes this.
> 
> 
>  To report this email as spam click https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg== .

So what's the answer, then?  Jérémie's patch makes only limited
assumptions; I think the #if is there simply to see if we can assume
two's complement arithmetic (it seems the preprocessor isn't keen on
"#if LONG_MIN - 1 == LONG_MAX", I suppose it's not required to use
"long" precision) in which case the test should work.  It might not
cover all real cases, but that's a lesser evil.

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog



Messages sorted by: Reverse Date, Date, Thread, Author