ash numeric overflow problem

Denys Vlasenko vda.linux at googlemail.com
Fri Jun 5 14:31:38 UTC 2009


On Fri, Jun 5, 2009 at 1:58 PM, Michael Abbott<michael at araneidae.co.uk> wrote:
> Next an oddity, this on both versions:
>
>        $ printf %x -2147483648
>        0sh: -2147483648: invalid number
>
> That's a shame.  But what about this one:
>
>        $ printf %x -2147483647
>        0sh: -2147483647: invalid number

Hehe. printf is funny. -2 is ok for "%u, but $TOO_BIG_POSITIVE
is not ok for %d:

# /usr/bin/printf '%d\n' 9223372036854775808
/usr/bin/printf: 9223372036854775808: Numerical result out of range
9223372036854775807
# /usr/bin/printf '%u\n' 9223372036854775808
9223372036854775808
# /usr/bin/printf '%u\n' -2
18446744073709551614

I fixed busybox to match this, will be in 1.15.x
--
vda


More information about the busybox mailing list