It does for /bin/sh, which is why I suggested perl rather than "echo $(($(sysctl -n hw.physmem)/1024/1024))" which will work on 64-bit arch but not 32-bit.
On 24 February 2014 23:49:08 GMT+00:00, Alexander Hall <alexan...@beard.se> wrote: > > >On February 25, 2014 12:27:41 AM CET, Stuart Henderson ><s...@spacehopper.org> wrote: >>On 2014-02-24, Fabian Raetz <fabian.ra...@gmail.com> wrote: >>> Hi misc@, >>> >>> while calculating my phys. memory (mb) with the >>> folllowing shellsript i get as a result -424. >>> >>> sysctl -n hw.physmem returns 3849830400 >>> >>> ------------ >>> #!/bin/sh >>> >>> phys_mem_bytes=`sysctl -n hw.physmem` >>> phys_mem_mb=`expr $phys_mem_bytes / 1024 / 1024` >>> echo $phys_mem_mb >>> ---------- >>> >>> so i tried >>> expr 2147483647 / 2 which returns 1073741824 while >>> expr 2147483648 / 2 returns -1073741824 >>> >>> >>> ksh(1) states that expr does Integer arithmetic. >>> So is this the expected behaviour or a bug? >> >>I don't see this discussed in ksh(1) - it's expr(1), /bin/expr on >>OpenBSD. > >IIRC i386 differs from amd64 (and other arches too). > >/Alexander > >>This uses 32-bit signed integer types, which are limited to 2^31-1, >>above >>which it wraps around. >> >>It may be possible to change this after we're done with release, but >>for >>now here's a quick workaround: >> >>phys_mem_mb=`perl -e "print int($phys_mem_bytes / 1024 / 1024);"`