Range of data types in C..

This is a discussion on Range of data types in C.. within the C Programming forums, part of the General Programming Boards category; Hello friends.., I need to process a very big, say a 16 digit number.. For example, i need to multiply ...

  1. #1
    Registered User
    Join Date
    Jan 2012
    Location
    Chennai, Tamil nadu, India
    Posts
    30

    Exclamation Range of data types in C..

    Hello friends.., I need to process a very big, say a 16 digit number.. For example, i need to multiply 2 to 421052631578948368.. But i'm totally puzzled... Which data type is apt for storing and manipulating it...? Or is there any need for using "dynamic memory allocation"..?Please help me to solve this situation friends..

  2. #2
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    The operation you said would still technically still fit in an unsigned long long type (uint64_t).

    However, it's relatively close to the limit, and if you need numbers over 18446744073709551615 (assuming 64-bit architecture), you'll need a big-number library.

    Dynamic memory allocation won't really do you any good unless you want to pack the numbers and re-write practically everything, but in that case, that's what a big-number library will do for you.

  3. #3
    Registered User
    Join Date
    Jan 2012
    Location
    Chennai, Tamil nadu, India
    Posts
    30

    Arrow @memcpy,,

    So, you mean, that there is a new datatype that has more range... isn't it..?

    If so, then how can we use that..? what's it syntax & its format specifier...?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,980
    long long and unsigned long long. As for the format specifier for the printf family of functions, that would be %lld and %llu respectively, though you may need to use %I64d and %I64u instead on Windows.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Jan 2012
    Location
    Chennai, Tamil nadu, India
    Posts
    30
    Well, are you saying it by your own guess..?

    It's not working on windows... I used all the format specifiers you mentioned...

    I have code::blocks compiler...Is there any modifications i need to do there..?
    Also, please mention the range of that data type and it's exact format specifer...

    Thanks..!!

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    5,884
    laserlight is not guessing. The maximum value that can be represented by an unsigned long long is guaranteed by the 1999 C standard to be at least 18446744073709551615, which exceeds the value you want to double (421052631578948368) by about 40 times.

    Not all compilers support a long long types though. mingw (the compiler suite used by code::blocks) does, although you may need to configure it (project settings or command line options for the compiler) to support the 1999 C standard (the 1989 C standard and the C++ standard do not support long long types).

    Given that you are providing minimal information, getting snippy - as you are - when advice does not work out exhibits a rather ........ty attitude on your part.
    Right 98% of the time, and don't care about the other 3%.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    2,372
    Quote Originally Posted by Rehman khan View Post
    I have code::blocks compiler
    Code::Blocks is an IDE; not a Compiler.
    Learn the name and version of your Compiler!

    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  8. #8
    Registered User
    Join Date
    Jan 2012
    Location
    Chennai, Tamil nadu, India
    Posts
    30

    Arrow @stahta01

    Yeah... It's correct.. i remember... So, i'm using Code::Blocks IDE, in that, GCC compiler... Now, can you explain how can i implement that datatype "uint64_t" in this compiler..? Will this GCC compiler supports "long long" & "unsigned long long" type..? If so, please mention how can i use this...? is it similar to "long" in usage..? Thanks...!

  9. #9
    Registered User DevoAjit's Avatar
    Join Date
    Jun 2011
    Location
    Ludhiana, Punjab, India, India
    Posts
    32
    Sir, can u tell me "is code::block can be used for compiling c program"

  10. #10
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,602
    Quote Originally Posted by DevoAjit View Post
    Sir, can u tell me "is code::block can be used for compiling c program"
    Yes, it can. It brings along MinGW with GCC, and all you have to do is make a project, create and fill a file and click the compile button.
    Devoted my life to programming...

  11. #11
    Registered User
    Join Date
    May 2009
    Posts
    2,372
    FYI: Code::Blocks IS NOT a Compiler!!

    Under Windows, Code::Blocks is sometimes packaged with the MinGW GCC Compiler.
    It IS NOT always packaged with the MinGW Compiler or any other Compiler.

    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  12. #12
    Registered User
    Join Date
    Feb 2012
    Posts
    4
    If you're using GCC, try using a long long long

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 12-04-2010, 12:34 AM
  2. Data Types
    By kas2002 in forum C Programming
    Replies: 1
    Last Post: 05-21-2009, 07:30 AM
  3. Replies: 2
    Last Post: 01-31-2008, 08:52 AM
  4. data types types...
    By gftmc in forum C++ Programming
    Replies: 3
    Last Post: 09-11-2006, 11:30 AM
  5. data types help
    By Bud in forum C Programming
    Replies: 2
    Last Post: 06-27-2002, 12:35 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21