Solved

How to declare an integer that can contain huge numbers like 10 in the 20th power?

Posted on 2008-06-14
4
347 Views
Last Modified: 2008-06-14
How to declare an integer that can contain huge numbers like 10 in the 20th power?
0
Comment
Question by:Chrysaor
  • 2
4 Comments
 
LVL 1

Expert Comment

by:mariourk
ID: 21785050
As far as I know, a 'long int' is the largest int you can declare (doubles aside)
An 'unsigned long int is 4 bytes long. It goes from 0 to 4.294.967.295
0
 
LVL 40

Accepted Solution

by:
evilrix earned 25 total points
ID: 21785139
>> An 'unsigned long int is 4 bytes long. It goes from 0 to 4.294.967.295
There is nothing in the C++ Standard that defines the size of an int.

"There are four signed integer types: signed char, short int, int, and long int. In this
list, each type provides at least as much storage as those preceding it in the list. Plain ints have the natural
size suggested by the architecture of the execution environment39) ; the other signed integer types are
provided to meet special needs."

The C99 Standard implements the type unsigned long long. The standard says this

 minimum value for an object of type long long int
LLONG_MIN -9223372036854775807 // -(263 - 1)

 maximum value for an object of type long long int
LLONG_MAX +9223372036854775807 // 263 - 1

 maximum value for an object of type unsigned long long int
ULLONG_MAX 18446744073709551615 // 264 - 1

Most modern C++ compilers will support this type, however, it is not defined in the C++ Standard (although this might change with C++09) and as such it isn't portable for use in C++ code.

http://home.att.net/~jackklein/c/inttypes.html
0
 
LVL 53

Assisted Solution

by:Infinity08
Infinity08 earned 25 total points
ID: 21785289
You can always use some bignum type.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21785292
For example :

        http://gmplib.org/
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adobe Customization Wizard XI issues 26 235
computer science syllabus 3 82
groupSumClump challenge 9 115
Message not shown 5 50
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article will show, step by step, how to integrate R code into a R Sweave document
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question