Not Yet Answered # Calculate the summation and subtraction of 100 digit integers.

ddanbe 2,503 Discussion Starter bundersi csurfer 422 Narue 5,707 Salem 5,138

0

Write say 20 digits down on paper and another 20 or so digits.

Now add them.

Do the same in your compurter program but use arrays and for loops and so on.

Happy computing

0

There are many cases exist, such as

1) -250+30

2) -25-(-30)

3) 25-30.....etc

how can i consider each cases ?

0

This isn't so easy.Even long integer cannot hold the complete length of the input you are assuming so we need to split the number into digit basis and proceed.

1>Take three array's A , B and C of size 100 each and initialize all their values to 0.

2>Take the input as A[0]=Units place of 1st number,A[1]=Tens place of 1st number and so on...(The same path to be followed for 2nd number with array B).

3>Take a int variable carry which is set to 0 initially.

4>if(A*>B )*

perform C=A-B;

// Remember carry is 0 only it is not manipulated

5>if(A*<B )*

set carry=1;

A=10+A;

now perform C=A-B;

6>In every loop check if carry is 1 (that is in the previous instance required a carry for subtraction) if not continue with step 4 or 5 which ever is proper.

7>If carry is 1 then perform:

A*=A -1; // i is present count of loop*

And then move on with step 4 or 5 which ever is proper

I suppose this is enough to give you a start.Now go on building this idea or a better idea of your own.(This idea still needs work and is not complete.)

0

>how can i consider each cases ?

By understanding them. If you don't understand what's going on then you clearly can't tell the computer how to do it. If you *do* understand what's going on, you can make such connections as realizing that -25-(-30) is actually the same as -25+30, you can move toward the sign of the second operand, and that the difference between negative and positive is the same as setting a flag and reversing direction when you hit 0.

Beyond that it's the same old basic arithmetic that you learned in the first grade.

1

> Beyond that it's the same old basic arithmetic that you learned in the first grade.

Do they still teach that?

Apparently not

http://www.literacytrust.org.uk/Database/businessupdate.html

The CBI surveyed more than 500 companies with 1.1million employees. They found that 52% of employers are dissatisfied with the basic literacy of school leavers and 50% with their basic numeracy, but 92% are satisfied with their IT skills. Half of employers said some teenagers were ‘unable to function in the workplace’ claiming they cannot make simple calculations in their heads, speak in an articulate manner or understand written instructions.

What's 92% measuring?

"Has the ability to switch the machine on, and move the mouse without strangling themselves with the cord".

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"

Here is the sample output that I ...

Hello All ...

Iam Getting An Error With try to excecute the stored procedure .

I have Have Sql database , the stored procedure like so :

```
USE [MPRS]
GO
/****** Object: StoredProcedure [dbo].[Search_Licenses_By_Number] Script Date: 26-Nov-16 8:06:52 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE ...
```

I don’t want at this stage work on a big separate project as I've already got plenty ...