Is it possible to take an input of range greater than what C/C++ provides? Is it possible to accept an input range greater than that of unsigned long long and even larger up to the range of 10^1000? If it is possible in C/C++, please answer how it can be done, thanks.
            Asked
            
        
        
            Active
            
        
            Viewed 2,714 times
        
    -1
            
            
        - 
                    2Yes, it's perfectly possible with a string or a big integer that supports that. – chris Sep 05 '14 at 09:56
- 
                    Use `std::string`/`std::vector` or a specific library ? – Jarod42 Sep 05 '14 at 09:56
- 
                    `unsigned long long` can't take 10^1000 as a input! – Sathish Sep 05 '14 at 09:57
- 
                    There is no data type to hold such value. However you can store them into vector of character and then write your own manipulation functions. – someone_ smiley Sep 05 '14 at 09:58
- 
                    @Sathish, `log10(2⁶⁴)` is 19. That's nowhere near enough. Your `unsigned long long` would have to be pretty darn wide. – chris Sep 05 '14 at 09:58
- 
                    @chiris is it possible to take 10^1000 as a input `unsigned long long`? – Sathish Sep 05 '14 at 10:03
2 Answers
8
            There's no bigint in C or C++, however library like this one can provide it: https://code.google.com/p/infint/
 
    
    
        CollioTV
        
- 684
- 3
- 13
- 
                    3I don't think "simulate" is the proper verb here. It *provides* bigint functionality. – Jongware Sep 05 '14 at 10:47
- 
                    
- 
                    @CollioTV Thanks but can you guide me how to set this header file named InfInt.h for my compiler, i am using codeblocks, and while i paste this header file inside this (C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.8.1\include) path, the compiler still fails to identify the header file. – lethal Sep 05 '14 at 10:55
- 
                    I'm really sorry but i'm not develloping on codeblocks... i don't really know how to import over library on this ide! @Jongware i'm sorry, english isn't my native language so id make mistake like this oftenly – CollioTV Sep 05 '14 at 11:04
- 
                    1No problem at all, and absolutely no need to apologize! We still understood what you meant. As far as English goes, "practice, practice, practice", and I consider SO a good place to do so! (You might find your answers may be improved 'silently', where someone edited your post. In this case I thought it wise to point out the difference; "simulate" is a valid term in programming, but it means something else.) – Jongware Sep 05 '14 at 14:37
4
            
            
        Input into a string. Then convert the string into the desired type.
If you use a library that provides types for large integers, such a library might also offer input functions.
 
    
    
        Oswald
        
- 31,254
- 3
- 43
- 68
 
    