[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ksh (pdksh) bug
On Fri, 2 Apr 2004, Han Boetes wrote:
> Otto Moerbeek wrote:
> > On Fri, 2 Apr 2004, Arkadiusz Miskiewicz wrote:
> > > Also it seem to overflow:
> > > $ echo $((16#ffffffff))
> > > -1
> >
> > Well, sh is supposed to do signed arithmetic following C rules, so
> > 16#ffffffff == -1 is ok, i think.
>
> Perhaps he means the lower precision?
>
> zsh-4.1.0% echo $((16#ffffffffffffff))
> 72057594037927935
> zsh-4.1.0% echo $((16#ffffffffffffffff))
> -1
>
> bash-2.05b$ echo $((16#ffffffffffffff))
> 72057594037927935
> bash-2.05b$ echo $((16#ffffffffffffffff))
> -1
>
> ksh $ echo $((16#ffffff))
> 16777215
> ksh $ echo $((16#ffffffff))
> -1
Yes, it would be nice to have larger precision. Posix says signed long
arithmetic is required; you may support larger precision (hey, you may
even swich to double precicion floating point if needed). BUT: these are
all extras which are _not_ required.
-Otto