| View previous topic :: View next topic |
| Author |
Message |
Overload Master Cheater
Reputation: 0
Joined: 08 Feb 2008 Posts: 293
|
Posted: Fri Jan 02, 2009 3:22 am Post subject: malloc help |
|
|
I'm just going to get right to the point.
I need to malloc an int enough space to hold 1000 digits.
I'm not sure how to allocate enough bytes equivalent to 1000(+1) digits.
Can anybody help me out here?
_________________
Blog
| Quote: | Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that |
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Fri Jan 02, 2009 4:02 am Post subject: |
|
|
| Code: | | malloc( ceil((floor(log(pow(10, 1000))/log(2)) + 1) / 4) ) |
The math is right, good luck finding a data type to hold pow(10, 1000).
|
|
| Back to top |
|
 |
Overload Master Cheater
Reputation: 0
Joined: 08 Feb 2008 Posts: 293
|
Posted: Fri Jan 02, 2009 9:21 pm Post subject: |
|
|
Flyte I don't understand. Because wouldn't all that add up to just a number? when it actual wants the size in bytes.
_________________
Blog
| Quote: | Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that |
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Fri Jan 02, 2009 10:04 pm Post subject: |
|
|
| Overload wrote: | | Flyte I don't understand. Because wouldn't all that add up to just a number? when it actual wants the size in bytes. |
Are you implying that a size is not a number?
_________________
|
|
| Back to top |
|
 |
Overload Master Cheater
Reputation: 0
Joined: 08 Feb 2008 Posts: 293
|
Posted: Sat Jan 03, 2009 2:44 am Post subject: |
|
|
| samuri25404 wrote: | | Overload wrote: | | Flyte I don't understand. Because wouldn't all that add up to just a number? when it actual wants the size in bytes. |
Are you implying that a size is not a number? |
So then
| Code: | | int result = (int)malloc( ceil((floor(log(pow(10, 1000))/log(2)) + 1) / 4) ) |
should work? I really am getting confused. lol
All i need is to make a variable able to hold 1000 digits. I know one way of doing this is using malloc. But i don't know exactly how.
_________________
Blog
| Quote: | Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that |
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sat Jan 03, 2009 3:33 am Post subject: |
|
|
it returns a pointer to your big ass block of memory.
go nuts there.
|
|
| Back to top |
|
 |
Overload Master Cheater
Reputation: 0
Joined: 08 Feb 2008 Posts: 293
|
Posted: Sat Jan 03, 2009 4:39 am Post subject: |
|
|
Mmkay thanks. I'll try it out and see what happens.
_________________
Blog
| Quote: | Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that |
|
|
| Back to top |
|
 |
|