- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Any one can explain this?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 07:40 PM
09-07-2006 07:40 PM
bcdb-p03:/script_file/OS#de_percent=$(( 47816844 * 10 ))
bcdb-p03:/script_file/OS#echo $de_percent
478168440
bcdb-p03:/script_file/OS#de_percent=$(( 47816844 * 100 ))
bcdb-p03:/script_file/OS#echo $de_percent
486717104
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 07:53 PM
09-07-2006 07:53 PM
Re: Any one can explain this?
I think the shell arithmetics only can handle 2^31 as maximum integer value (I think one bit is required for the sign)
The man page should mention the limitations.
You could resort to bc or perl, python for big ints.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 10:56 PM
09-07-2006 10:56 PM
Re: Any one can explain this?
A slight overrun will lead to negative numbers.
Now remember, that a '-' may be interpreted by the 'echo' or 'print' as an option.
My Sun ksh (64Bit) tells:
print $((47816844 * 100000000000))
4781684400000000000
print $((47816844 * 1000000000000))
print -- "$((47816844 * 1000000000000))"
-7523388221128654848
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2006 08:37 PM
09-10-2006 08:37 PM
Re: Any one can explain this?
Thanks for the reply. but how can I resolve this question,I need to write a script like this to check the memory treadhold,but if the memory is large,the script will get wrong result.plz give me further help
########### check memory added 09/04/2007
thresholdmem=10
de_phy=`more /var/adm/syslog/syslog.log|grep -i phy|grep available|awk '{print $7}'`
de_free=`more $State_File |grep Memory:|awk '{print $8}'|sed 's/K//p'`
de_percent=$(( $de_free * 100 / $de_phy ))
if [ $thresholdmem -gt $de_percent ]
then
echo "Current free Memory is : $de_percent %" >> $output_file
echo "Critical: Found that there is Memory issue! plz check it ASAP!!\n" >> $output_file
grep -i USERNAME $State_File >> $output_file
typeset i=1
while read -r yy
do
if [ $i -gt 15 ]
then
printf "%s \n" "$yy" >> $State_File2
fi
if [ $i -gt 1115 ]
then
break
fi
let i=i+1
done < $State_File
sort -r -k 8,8 $State_File2 >> $new_file2
typeset a=1
while read -r xx
do
if [ $a -gt 0 ]
then
printf "%s \n" "$xx" >> $output_file
fi
if [ $a -gt 20 ]
then
break
fi
let a=a+1
done < $new_file2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2006 09:48 PM
09-10-2006 09:48 PM
Solutionfirst choice:
come to lower numbers, in computing the values you use not in KB but MB - so you have a factor of 1/1024.
Another alternative would be the use of dc/awk/perl to get 64Bit integer arithmetik or floating point calculation.
E.G.
print "47816844 100*p" | dc
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2006 10:48 PM
09-10-2006 10:48 PM