- #1

Jameson

Gold Member

MHB

- 4,538

- 13

Jameson

You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- Thread starter Jameson
- Start date

- #1

Jameson

Gold Member

MHB

- 4,538

- 13

Jameson

- #2

saltydog

Science Advisor

Homework Helper

- 1,591

- 3

Jameson said:

Jameson

You need to use multi-precision arithmetic. You can write your own or can get the code elsewhere. Essentially, the digits of a number (real or integer) are stored separately in arrays, classes whatever. And you do the arithmetic on the separate digits. There are elegant algorithms for doing subtraction, multiplication, division, and addition in multi-precision. Should be able to google for the algorithms.

- #3

VietDao29

Homework Helper

- 1,426

- 3

I think what you need is inputs of string. Then you can analyze the string and calculate them. For example, you want calculate 35 + 244

You will ask the user give you 2 strings "35", and "244", and the operator as well, i.e. :"+".

And here is what I did:

+ Make the 2 numbers have the same length "035", and "244"

+ Use the loop to convert to number and calculate each degit backwards, i.e. : 5 + 4, 3 + 4, and 0 + 2.

+ Print out the result.

It's a little bit more tricky if you work with rational numbers like "3.5", "2.44".

I finished the addition, subtraction, as well as multiplication, but not in C++, I programmed in DB. If you want, I can show you my work.

Viet Dao,

- #4

__int64 variable;

I'm not sure how many digits that will allow, but it's pretty big.

- #5

dduardo

Staff Emeritus

- 1,901

- 3

The largest unsigned 64bit integer is 2^64-1 = 18446744073709551615

The largest signed 64bit integer is 2^63-1 = 9223372036854775807

The largest signed 64bit integer is 2^63-1 = 9223372036854775807

Last edited:

- #6

Hurkyl

Staff Emeritus

Science Advisor

Gold Member

- 14,967

- 19

Of course dduardo means 2^64 - 1 = 18446744073709551615

__int64 will only work in microsoft compilers. (As will _int64 and int64)

In *nix systems, you'll want int64_t, or uint64_t. (they're in <inttypes.h>, I think)

For many compilers, long long will do it.

But as mentioned, you'll want to find a big number package.

__int64 will only work in microsoft compilers. (As will _int64 and int64)

In *nix systems, you'll want int64_t, or uint64_t. (they're in <inttypes.h>, I think)

For many compilers, long long will do it.

But as mentioned, you'll want to find a big number package.

Last edited:

- #7

dduardo

Staff Emeritus

- 1,901

- 3

Hurkyl, your right. The signed figure is still correct.

- #8

Asphyxi8

- 13

- 0

Headache. . . headache. . .

Share:

- Last Post

- Replies
- 25

- Views
- 1K

- Last Post

- Replies
- 29

- Views
- 5K

- Replies
- 1

- Views
- 147K

- Last Post

- Replies
- 2

- Views
- 2K

- Last Post

- Replies
- 1

- Views
- 3K

- Last Post

- Replies
- 4

- Views
- 2K

- Replies
- 6

- Views
- 3K

- Replies
- 0

- Views
- 2K

Calculators
How do I calculate roots with the 15c

- Last Post

- Replies
- 1

- Views
- 4K

- Replies
- 4

- Views
- 5K