very thanks to all :D 2010/7/15 Andreas Mohr <[email protected]>
> On Thu, Jul 15, 2010 at 12:00:04PM +0200, > [email protected] wrote: > > Hey all I have a big problem with openwrt! > > > > In a bash shell if i write this command > > printf "%d\n" "`echo "255.255.255.255" | awk -F\. '{printf "%d", > > ($4)+($3*256)+($2*256*256)+($1*256*256*256)}'`" > > i obtain > > 2147483647 > > that is wrong! > > The question here would be WHAT exactly is wrong here ;) > Probably not this shell... > > %d is a format string for a _signed_ integer, not the unsigned > expression that is being evaluated here. > And with common systems an integer value is specified as 32bit, > resulting in this INT_MAX value for any values _larger_ than that. > > > If i put the same command in my gentoo bash shell i obtain 4294967295 > that > > is the good value how to fix this ? > > %u would fix that, or perhaps better use %lu (or better %llu?) for > higher probability to get the correct value. > OTOH since an IPv4 address will always remain 32bit, %u is fully > sufficient and thus the exactly adapted and proper solution. > > HTH, > > Andreas Mohr > _______________________________________________ > openwrt-devel mailing list > [email protected] > https://lists.openwrt.org/mailman/listinfo/openwrt-devel >
_______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
