Re: How can I get Inline::C to deal with big number?

2005-03-28 Thread John W. Krahn
Steven Schubiger wrote: > On 26 Mar, Edward Wijaya wrote: > >>What could be the problem? >>Is there a way to solve it > > I assume, the typedef doesn't value the "hooked" malloc, thus, > I recommend: > > long double *big_double; > big_double = (long double *) malloc(2*sizeof(long double));

Re: How can I get Inline::C to deal with big number?

2005-03-28 Thread Steven Schubiger
On 26 Mar, Edward Wijaya wrote: > What could be the problem? > Is there a way to solve it I assume, the typedef doesn't value the "hooked" malloc, thus, I recommend: long double *big_double; big_double = (long double *) malloc(2*sizeof(long double)); -- The trouble with having an open mind, of

Re: How can I get Inline::C to deal with big number?

2005-03-26 Thread Edward Wijaya
Dear Steven, Sorry, don't mean to nitpick. On Sat, 26 Mar 2005 23:09:26 +0800, Steven Schubiger <[EMAIL PROTECTED]> wrote: On 26 Mar, Edward Wijaya wrote: It's fine, as it is. Typedefs most often reside in header files, although, they can be used in the main file without suffer. As per your sug

Re: How can I get Inline::C to deal with big number?

2005-03-26 Thread Steven Schubiger
On 26 Mar, Edward Wijaya wrote: > Sorry my C is barely Novice. > Where can I put this snippet in my C subroutine? It's fine, as it is. Typedefs most often reside in header files, although, they can be used in the main file without suffer. If you ever should get bored, read the Perl Sources. --

Re: How can I get Inline::C to deal with big number?

2005-03-26 Thread Edward Wijaya
On Sat, 26 Mar 2005 22:31:52 +0800, Steven Schubiger <[EMAIL PROTECTED]> wrote: typedef (malloc(2*sizeof(long double))) Big_Double; Big_Double var; Sorry my C is barely Novice. Where can I put this snippet in my C subroutine? like this: [snip code] __END__ __C__ typedef (malloc(2*sizeof(long do

Re: How can I get Inline::C to deal with big number?

2005-03-26 Thread Steven Schubiger
On 26 Mar, Edward Wijaya wrote: >> printf("%i\n", sizeof(long double)); > > It gives: > 12 Fine, it was even 2 Bytes bigger than excepted. typedef (malloc(2*sizeof(long double))) Big_Double; Big_Double var; var should measure 24 bytes in size, which should suffice; if not, increment the factor

Re: How can I get Inline::C to deal with big number?

2005-03-26 Thread Steven Schubiger
> On 26 Mar, Edward Wijaya wrote: >> Try "long double" instead, which gives you 10 Bytes and >> the format char %Lf. > Still wont' do. It still return 'inf' for N>500 Another solution would be, dynamically allocating memory: long double var; var = (long double *) malloc(2*sizeof(long double)

Re: How can I get Inline::C to deal with big number?

2005-03-26 Thread Steven Schubiger
On 26 Mar, Edward Wijaya wrote: >> Try "long double" instead, which gives you 10 Bytes and >> the format char %Lf. > Still wont' do. It still return 'inf' for N>500 What does printf("%i\n", sizeof(long double)); tell you? The byte sizes of variable types can vary from platform to platform. --

Re: How can I get Inline::C to deal with big number?

2005-03-26 Thread Edward Wijaya
Hi Steven, On Sat, 26 Mar 2005 22:08:44 +0800, Steven Schubiger <[EMAIL PROTECTED]> wrote: Try "long double" instead, which gives you 10 Bytes and the format char %Lf. Still wont' do. It still return 'inf' for N>500 -- Edward WIJAYA Singapore -- To unsubscribe, e-mail: [EMAIL PROTECTED] For addi

Re: How can I get Inline::C to deal with big number?

2005-03-26 Thread Steven Schubiger
On 26 Mar, Edward Wijaya wrote: >> Change every occurence of the word "float" , in your script, >> to "double". > > It worked, but still limited. It overflowed when N>500. > Most of the value of N, I use are around 1000-2000. > > Any other possibility? Try "long double" instead, which gives you

Re: How can I get Inline::C to deal with big number?

2005-03-26 Thread Edward Wijaya
Hi Zentara, Thanks for the reply. On Sat, 26 Mar 2005 21:35:17 +0800, zentara <[EMAIL PROTECTED]> wrote: Change every occurence of the word "float" , in your script, to "double". It worked, but still limited. It overflowed when N>500. Most of the value of N, I use are around 1000-2000. Any other p

How can I get Inline::C to deal with big number?

2005-03-26 Thread Edward Wijaya
Hi, I have the following code that uses Inline::C to compute factorial. The problem is that whenever I use large N (>30) it began to return "INF". I thougtht my C implementation already cater large number by using "float"? Additionally I have already added Math::Pari as an attempt to solve the prob