Calculation - Result not accurate if numbe too big


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Calculation - Result not accurate if numbe too big
# 1  
Old 06-13-2006
Calculation - Result not accurate if numbe too big

Dear all,

Below is my script,

totalCount=57006427
totalSummCount=1207590
let percentageSumTmp1=${totalCount}-${totalSummCount}
let percentageSumTmp2=${percentageSumTmp1}*100

The expected result for percentageSumTmp2 should be (5579883700),
but when I execute the script in unix env i get 1284916404 ..
If I remove 1 digit number of the totalCount , then i able to get correct result Smilie

anyone , know how to fix it ?


Many thanks.
# 2  
Old 06-13-2006
I do not really know... Perhaps because of shell limits.
Though you could do the operations in HEX:
Code:
totalCount=0x365D95B
totalSummCount=0x126D26
let percentageSumTmp1=${totalCount}-${totalSummCount}
let percentageSumTmp2=${percentageSumTmp1}*100

echo $percentageSumTmp2

This returns "5579883700"... Smilie
# 3  
Old 06-13-2006
# 4  
Old 06-13-2006
Quote:
Originally Posted by vino

Sure! It's usually available... I suppose awk would also do the job... Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Facing problem while printing accurate decimal value

Hi, I have a file tp.txt having below data CE2DD,N,5055,16.12.2013,3.114,12195.89,MVR,003388,Web::00000005055,Web Payment and i am using below code to print the values for var_amt_pay in `awk -F',' '{ arr += $6} END {for (i in arr) {print i "," arr } }' tp.txt` do ... (2 Replies)
Discussion started by: ranabhavish
2 Replies

2. Shell Programming and Scripting

Output is not Accurate

list db directory |grep alias |awk '{print "connect to ",$4}' In a shell script the below line should display output as below connect to <DATABASENAME> but its throwing error like Syntax Error The source line is 1. The error context is {print connect to,... (8 Replies)
Discussion started by: rocking77
8 Replies

3. Hardware

time accurate simulator

Hi all, Does anybody know how to build a cycle accurate simulator? I've looked at QEMU and SESC simulator, but they are only cycle accurate for the CPU part. I'm looking for a simulator which can estimate the performance including CPU and I/O. For example, when I configure the simulator by SSD... (2 Replies)
Discussion started by: qqkk88
2 Replies

4. UNIX for Dummies Questions & Answers

How big is too big a config.log file?

I have a 5000 line config.log file with several "maybe" errors. Any reccomendations on finding solvable problems? (2 Replies)
Discussion started by: NeedLotsofHelp
2 Replies

5. UNIX for Advanced & Expert Users

Retrieving accurate file timestamp

Hi Gurus, The requirement is to collect the timestamp of soft links and collect it in a file in the following pattern: This is the expected output: Pattern: MM/DD/YYYY hh:mi:ss filename Example: 12/26/2008 10:31:09 <Filename>.zip The closest way I could get was this: ls... (8 Replies)
Discussion started by: jidsh
8 Replies

6. Programming

how to check whether given numbe ris hex or not

helo I have particular number lets say 0x56 now thropugh c program how to check this number is hex or not Regards, Amit (4 Replies)
Discussion started by: amitpansuria
4 Replies

7. Solaris

How accurate is the HCL for Solaris 10?

I have a Sun Ultra 5 that is running Solaris 8. I believe I meet the minimum requirements for Solaris 10 but the Ultra 5 is not on the HCL. This will be my first ever Solaris upgrade so do I follow the HCL guidelines? TiA (4 Replies)
Discussion started by: PapaPark
4 Replies

8. UNIX for Dummies Questions & Answers

How to view a big file(143M big)

1 . Thanks everyone who read the post first. 2 . I have a log file which size is 143M , I can not use vi open it .I can not use xedit open it too. How to view it ? If I want to view 200-300 ,how can I implement it 3 . Thanks (3 Replies)
Discussion started by: chenhao_no1
3 Replies
Login or Register to Ask a Question