By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,902 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

How does a 32 bit windows OS have a calculator that can sum numbers bigger than Long?

P: n/a
Hi ppl
A simple question! I'm afraid it can be a bit silly, but I'm not an experienced programmer
How does a 32 bit windows OS, comes with a calculator where you can sum really big numbers, over the limit of 32 bit integer (2,147,483,647).
The problem is I want to make a calculator in C#. I know a solution would be use Long Int, but what if I want to add numbers even bigger than Long Int?
So consider a solution without using Long Int.
Don't be stressed about this, as it's not for a job, or academic work, it's just i can't understand how the calculator does that in a 32 bit OS, and it can't be done in programming languages (at least strait x+z=y), so there must be a workaround !
Thanks in advance! And sorry if the question is silly
Nov 5 '10 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 8,916
Well the calculator in Windows, AFAIK, does maths up to 64 bits and for a very long time the Microsoft C/C++ compiler has had a proprietary 64bit integer type __int64 and I always assumed that the calculator used that.

Doesn't C# use .NET and doesn't .NET have a 64bit type?

However if you want to have more than 64bits in an integer it is fairly easy to write a class that will support an integer of any bit length.

And in fact there are a number of such classes available on the internet in various languages including C# (search for BigInt).

The basic strategy is to store digits in the class and then perform the arithmetic on those digits much as you did sums when you were at school. You can choose a very high base for your digits (say base 65536) which can make the class fairly efficient when using small numbers as well as able to deal with large numbers.
Nov 5 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.