[Ninux-Wireless] problem with big integer on openwrt
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! If i put the same command in my gentoo bash shell i obtain 4294967295 that is the good value how to fix this ? ___ Wireless mailing list Wireless@ml.ninux.org http://ml.ninux.org/mailman/listinfo/wireless
Re: [Ninux-Wireless] problem with big integer on openwrt
I think awk could be the point. My system (ubuntu) gives the correct answer. l...@luca-laptop:~$ which awk /usr/bin/awk l...@luca-laptop:~$ file /usr/bin/awk /usr/bin/awk: symbolic link to `/etc/alternatives/awk' l...@luca-laptop:~$ file /etc/alternatives/awk /etc/alternatives/awk: symbolic link to `/usr/bin/gawk' l...@luca-laptop:~$ file /usr/bin/gawk /usr/bin/gawk: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped l...@luca-laptop:~$ awk --version GNU Awk 3.1.6 [...] So, what is 'awk' in a openwrt box? ___ Wireless mailing list Wireless@ml.ninux.org http://ml.ninux.org/mailman/listinfo/wireless
Re: [Ninux-Wireless] problem with big integer on openwrt
The problem is not Openwrt but awk that cannot handle big number on small device :( bash can than i fixed with this printf %d\n $(( (`echo 255.255.255.255 | awk -F\. '{printf %d, ($4)}'`)+ (256*`echo 255.255.255.255 | awk -F\. '{printf %d, ($3)}'`) + (256*256*`echo 255.255.255.255 | awk -F\. '{printf %d, ($2)}'`) + (256*256*256*`echo 255.255.255.255 | awk -F\. '{printf %d, ($4)}'`) )) 2010/7/15 Gioacchino Mazzurco gmazzurc...@gmail.com 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! If i put the same command in my gentoo bash shell i obtain 4294967295 that is the good value how to fix this ? ___ Wireless mailing list Wireless@ml.ninux.org http://ml.ninux.org/mailman/listinfo/wireless
Re: [Ninux-Wireless] problem with big integer on openwrt
On 07/15/2010 12:01 PM, Gioacchino Mazzurco wrote: The problem is not Openwrt but awk that cannot handle big number on small device :( bash can than i fixed with this printf %d\n $(( (`echo 255.255.255.255 | awk -F\. '{printf %d, ($4)}'`)+ (256*`echo 255.255.255.255 | awk -F\. '{printf %d, ($3)}'`) + (256*256*`echo 255.255.255.255 | awk -F\. '{printf %d, ($2)}'`) + (256*256*256*`echo 255.255.255.255 | awk -F\. '{printf %d, ($4)}'`) )) Also, Try this command: echo 255.255.255.255 | awk -F\. '{printf $4+$3*256+$2*256*256+$1*256*256*256\n}' | bc -- Il Piuma ___ Wireless mailing list Wireless@ml.ninux.org http://ml.ninux.org/mailman/listinfo/wireless