Fwd: [sllug-members]: Fiber for Salt Lake and Utah Movement

2007-09-21 Thread Steve
Figured I'ld forward this from Slug to Plug, since it's relevant. -- Forwarded message -- From: Thomas S Hatch <[EMAIL PROTECTED]> Date: Sep 21, 2007 11:42 PM Subject: [sllug-members]: Fiber for Salt Lake and Utah Movement To: Salt Lake Linux Users Group Discussions <[EMAIL PROTECT

Re: itoa'd you so?

2007-09-21 Thread Levi Pearson
Charles Curley <[EMAIL PROTECTED]> writes: > I like it. A few points. > > * It is base ten only. My solution is much more general. Need base 36? > Recall that base 10 was not specified in the original problem. But > your method can be adapted at the cost of: > > * expanding the lookup table,

Re: itoa'd you so?

2007-09-21 Thread Michael L Torrie
Steve wrote: > Correct me if I'm wrong, but I thought inlining was not a guarantee, > but only a suggestion. You are correct, but as long as optimization isn't turned completely off, I'd be very shocked if the compiler didn't follow the suggestion. /* PLUG: http://plug.org, #utah on irc.freenode.

Re: itoa'd you so?

2007-09-21 Thread Steve
Correct me if I'm wrong, but I thought inlining was not a guarantee, but only a suggestion. On 9/21/07, Michael L Torrie <[EMAIL PROTECTED]> wrote: > Steve wrote: > > How much function call overhead is this incurring? > > Would it run faster if you took the digit function and just embedded > > it

Re: itoa'd you so?

2007-09-21 Thread Levi Pearson
Steve <[EMAIL PROTECTED]> writes: > How much function call overhead is this incurring? > Would it run faster if you took the digit function and just embedded > it directly into the itoa function? Should be 0, since he declared it to be inline. The compiler could always ignore that, though. And

Re: itoa'd you so?

2007-09-21 Thread Michael L Torrie
Steve wrote: > How much function call overhead is this incurring? > Would it run faster if you took the digit function and just embedded > it directly into the itoa function? Practically nothing, since it's declared as "inline." The compiler *is* embedding it directly in the itoa function. >

Re: itoa'd you so?

2007-09-21 Thread Steve
How much function call overhead is this incurring? Would it run faster if you took the digit function and just embedded it directly into the itoa function? On 9/21/07, Charles Curley <[EMAIL PROTECTED]> wrote: > On Fri, Sep 21, 2007 at 08:37:11PM -0600, Levi Pearson wrote: > > Charles Curley <[EMA

Re: itoa'd you so?

2007-09-21 Thread Charles Curley
On Fri, Sep 21, 2007 at 08:37:11PM -0600, Levi Pearson wrote: > Charles Curley <[EMAIL PROTECTED]> writes: > > > > Have we beaten this thing into the ground yet? > > Not quite yet. Try this one: I like it. A few points. * It is base ten only. My solution is much more general. Need base 36? Re

Re: CMS recommendations?

2007-09-21 Thread Steve
For anyone interested I have the site up and operational, and will be adding content shortly. The URL is http://www.dreamrpgonline.com/ Sincerely, Steve On 9/21/07, Steve <[EMAIL PROTECTED]> wrote: > Ok it looks like Drupal is the natural choice for this. > > As to the other questions. > > The si

Re: itoa'd you so?

2007-09-21 Thread Levi Pearson
Charles Curley <[EMAIL PROTECTED]> writes: > > Have we beaten this thing into the ground yet? Not quite yet. Try this one: void itoa(int n, char s[]) { int i, sign; sign = n; i = 0; do { s[i++] = "0123456789"[abs(n % 10)]; } while ( n /= 10 ); if (sign < 0) s[i++] = '-';

Re: itoa'd you so?

2007-09-21 Thread Charles Curley
On Fri, Sep 21, 2007 at 04:11:44PM -0600, Dave Smith wrote: > Charles Curley wrote: > >Ah, good. Did you finally get around to looking at the solution I > >posted to this thread two days ago? > > > > It also crashes at random points (sometimes after 6700 invocations, > sometimes after 5001, som

Re: itoa'd you so?

2007-09-21 Thread Levi Pearson
Charles Curley <[EMAIL PROTECTED]> writes: > > Picky, picky. > > OK, 0 is a likely value in an embedded context, so I added code for > that. I have two return statements, which would save a branch > instruction on some compilers, but maybe not on others. > > I didn't handle INT_MIN because it's a b

Re: itoa'd you so?

2007-09-21 Thread Charles Curley
On Fri, Sep 21, 2007 at 04:11:44PM -0600, Dave Smith wrote: > Charles Curley wrote: > >Ah, good. Did you finally get around to looking at the solution I > >posted to this thread two days ago? > > > > Yup, it's pretty nice with only a few warts. It doesn't work for zero or > INT_MIN. Picky, pic

Re: itoa'd you so?

2007-09-21 Thread Levi Pearson
Steve <[EMAIL PROTECTED]> writes: > So does this presnet a real world bug, or would the user just perform > some bounds checking prior to handing it off to the function? Well, you could specify that your function isn't required to work on the smallest int value representable in your int, but that

Re: itoa'd you so?

2007-09-21 Thread Levi Pearson
Dave Smith <[EMAIL PROTECTED]> writes: > > My version skips the strcat() at the end of itoa() in favor of just > returning a char* that points at where my itoa() put the string in the > specified buffer. The caller can then know where to find the int. It > saves a bit of time, but at the slight cos

Re: itoa'd you so?

2007-09-21 Thread Steve
So does this presnet a real world bug, or would the user just perform some bounds checking prior to handing it off to the function? Something like... if(myval < 0 && abs(myval) == myval) or maybe if(myval == INT_MIN) On 9/21/07, Dave Smith <[EMAIL PROTECTED]> wrote: > Levi Pearson wrote: > > Th

Re: itoa'd you so?

2007-09-21 Thread Dave Smith
Levi Pearson wrote: The answer lies in 2's complement binary representation of integers. There aren't the same number of integers to the left and to the right of 0; there's one more to the left. So, the absolute value of the smallest representable integer isn't representable in the same number o

Re: itoa'd you so?

2007-09-21 Thread Dave Smith
Charles Curley wrote: Ah, good. Did you finally get around to looking at the solution I posted to this thread two days ago? Yup, it's pretty nice with only a few warts. It doesn't work for zero or INT_MIN. It also crashes at random points (sometimes after 6700 invocations, sometimes after

Re: itoa'd you so?

2007-09-21 Thread Bryan Sant
On 9/21/07, Levi Pearson <[EMAIL PROTECTED]> wrote: > The answer lies in 2's complement binary representation of integers. > There aren't the same number of integers to the left and to the right > of 0; there's one more to the left. So, the absolute value of the > smallest representable integer is

Re: itoa'd you so?

2007-09-21 Thread Charles Curley
On Fri, Sep 21, 2007 at 02:59:05PM -0600, Dave Smith wrote: > Steve wrote: > > Anyway, I revised my implementation today to not *need* a log10 function > by writing the ascii value into the *end* of the buffer, right-to-left, > least-significant to most-significant, and then it returns a pointe

Re: CMS recommendations?

2007-09-21 Thread Steve
Ok it looks like Drupal is the natural choice for this. As to the other questions. The site should hopefully become a full fledged online community. At the present time I'm only looking at a single site. This is not already a business, at the moment there are no plans for a business other than m

Re: itoa'd you so?

2007-09-21 Thread Levi Pearson
Dave Smith <[EMAIL PROTECTED]> writes: > I did, however, find another special case (in addition to zero), and > that is INT_MIN. If you can figure out why INT_MIN is a special case, > you get bonus Plug Karma points. The answer lies in the result of the > following C expression: > >abs( INT_MI

Re: itoa'd you so?

2007-09-21 Thread Steve
/me drools I have GOT to see this code Dave! On 9/21/07, Dave Smith <[EMAIL PROTECTED]> wrote: > Steve wrote: > > Since the sprintf function is slowing down on the log10 due to > > floating point arithmetic, I wonder if a further optimization could be > > made by rewriting the log10 function in as

Re: itoa'd you so?

2007-09-21 Thread Dave Smith
Steve wrote: Since the sprintf function is slowing down on the log10 due to floating point arithmetic, I wonder if a further optimization could be made by rewriting the log10 function in assembler to take advantage of the floating point registers? I found that writing an integer-based log10

Re: itoa'd you so?

2007-09-21 Thread Levi Pearson
Steve <[EMAIL PROTECTED]> writes: > Since the sprintf function is slowing down on the log10 due to > floating point arithmetic, I wonder if a further optimization could be > made by rewriting the log10 function in assembler to take advantage of > the floating point registers? > My ASM is way to rus

Re: itoa'd you so?

2007-09-21 Thread Steve
Since the sprintf function is slowing down on the log10 due to floating point arithmetic, I wonder if a further optimization could be made by rewriting the log10 function in assembler to take advantage of the floating point registers? My ASM is way to rusty to attempt this right now but I think I'l