How to add two large values


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to add two large values
# 1  
Old 05-20-2005
How to add two large values

Hi,

Gives me wrong value when,

$ echo `expr 2221753117 + 299363384`
-1773850795

How to overcome this?

Appreciate any help on this.

-Om
# 2  
Old 05-20-2005
#/bin/ksh
number1=9888673663678977
number2=79872372378273472379837
result=`bc << EOF
$number1 + $number2
EOF`
echo "$number1 + $number2 = $result"



Try this script.
# 3  
Old 05-20-2005
Thanks for your script. It helped me a lot today.......

Thanks Again.
-Om
# 4  
Old 05-21-2005
or more simply
result=`echo "2221753117 + 299363384" | bc`

Cheers
ZB
# 5  
Old 06-10-2005
or
Code:
dc -e '2221753117 299363384+p'

# 6  
Old 06-10-2005
You can simply try as,

echo $((2221753117 + 299363384))

hth.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to add line breaks to perl command with large text in single quotes?

Below code extracts multiple field values from XML into array and prints all in one line. perl -nle '@r=/(?: jndiName| authDataAlias| value| minConnections| maxConnections| connectionTimeout| name)="(+)/g and print join ",",$ENV{tIPnSCOPE},$ENV{pr ovider},$ENV{impClassName},@r' server.xml ... (4 Replies)
Discussion started by: kchinnam
4 Replies

2. Shell Programming and Scripting

Reoccuring peak values in large data file and print the line..

Hi i have some large data files that contain several fields and rows the data in a field have a numeric value that is in a sine wave pattern what i would like todo is locate each peak and pick the highest value and print that complete line. the data looks something like this it is field nr4 which... (4 Replies)
Discussion started by: ninjaunx
4 Replies

3. Shell Programming and Scripting

Reading off values from a large file

Hi, I have a large output file (star.log), with many lines of the following type *** T vavg unburnt: 723.187 / burnt: 2662.000 What I would like to do is pick the values 723.187 and 2662.000 and What I've got so far is awk '/unburnt:.*burnt:/{Tu=$6;Tb=$NF}END{print Tu, Tb}'... (6 Replies)
Discussion started by: lost.identity
6 Replies

4. UNIX for Dummies Questions & Answers

Help with solution to add together columns of large file

Hi everyone. I have a file with ~500 columns and I would like to perform a simple calculation on every two columns. The file looks like this: $cat input id A B C D E F.....X 1 2 4 2 3 4 1 n 2 4 6 4 6 4 5 n 3 4 7 5 2 2 3 n 4 ... (5 Replies)
Discussion started by: torchij
5 Replies

5. Shell Programming and Scripting

How to remove a subset of data from a large dataset based on values on one line

Hello. I was wondering if anyone could help. I have a file containing a large table in the format: marker1 marker2 marker3 marker4 position1 position2 position3 position4 genotype1 genotype2 genotype3 genotype4 with marker being a name, position a numeric... (2 Replies)
Discussion started by: davegen
2 Replies

6. Shell Programming and Scripting

Comparison between 2 large lists with Getting VALUES from one into the other

hi, I have 2 large lists: LIST A: containes 6 fields of many entries (VARIABLE number), like: 2011-07-10 | 18:19:47 | 38037300 | 9647808003122 | 2 | success LIST B: containes 3 fields & 183 entries (FIXED number), like: 9647805651885 9647805651885 SCP_10 What I want is a... (8 Replies)
Discussion started by: amurib
8 Replies

7. Shell Programming and Scripting

Add values < or eq to 1000

make a list based on the first column key and corresponding value (2nd column-bold) in input1 search values that less than or equal to 1000 (2nd column-bold)in the input2 of the same key along with other columns. input x1 10 hfffhf 646474_jhg x2 100 jkfgjj 765755_jg input2 x1... (16 Replies)
Discussion started by: repinementer
16 Replies

8. Shell Programming and Scripting

Large pipe delimited file that I need to add CR/LF every n fields

I have a large flat file with variable length fields that are pipe delimited. The file has no new line or CR/LF characters to indicate a new record. I need to parse the file and after some number of fields, I need to insert a CR/LF to start the next record. Input file ... (2 Replies)
Discussion started by: clintrpeterson
2 Replies

9. Shell Programming and Scripting

Split large file and add header and footer to each small files

I have one large file, after every 200 line i have to split the file and the add header and footer to each small file? It is possible to add different header and footer to each file? (7 Replies)
Discussion started by: ashish4422
7 Replies

10. Shell Programming and Scripting

Help In Calculation of large values in loop

Hi Gurus, I am writing a shell script in which i need to strip out the numbers from file the values are unknown i. e. the range cannot be predicted.. and in my current program the sum of values is not coming as desired i think the value of calculation is crossing the range i.e. after some... (6 Replies)
Discussion started by: sandeepb
6 Replies
Login or Register to Ask a Question