I need to use huge data (10^100) in a Variable in C?
How can i implement it?

Double,float ranges are low..

Suggest me in this..

Thanks in advance!!

There's plenty of big-number libraries on the net, or if you have the programming ability, you can write your own big-number class.

struct BigInt {
  // ...
};

int main( void ) {
}

Well a weird idea but you can even split the number into digits and store in a linked list or an array or something else... flex your brain and you will do great !!!

You don't always have to store the actual value the way float and double do. If the problem allows it, you can write your own data type that uses exponent representation just like you showed in your post:

typedef struct 
{
    long base;
    long exponent;
} exponent_t;

Then do math on it like you learned in grade school. :)

commented: Good advice. +3

>There's plenty of big-number libraries on the net, or if you have the programming ability, you can write your own big-number class.
Huh? A class in C ??

:P

>There's plenty of big-number libraries on the net, or if you have the programming ability, you can write your own big-number class.
Huh? A class in C ??

:P

It's practically the same thing, in my example I used a struct anyway.

>It's practically the same thing, in my example I used a struct anyway.
Not in C. A C compiler do not know what a class is.
I agree that struct and class are related ( and they are the same thing in C++ ( except for the default access providers) ) but they can mean a lot of difference to a considerate programmer.
If you meant "class" literally (perhaps you're too close to C++, Never mind happens to everyone :) ), then it is acceptable.
But do remember that C++ structs are not same as C structs

If your going towrite your own, think of how you would do it on paper. I tried to write one for any size number (limited by memory). Didn't work but the concept is pritty simple.

commented: your signature makes me laugh +11
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.