Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!wuarchive!emory!att!cbnews!cbnewsm!lfd From: lfd@cbnewsm.att.com (leland.f.derbenwick) Newsgroups: comp.lang.c Subject: Re: Source for "integer to ascii" and multiple file search-n-replace Message-ID: <1990Nov27.224111.24038@cbnewsm.att.com> Date: 27 Nov 90 22:41:11 GMT References: <318@cti1.UUCP> <1990Nov20.014110.16982@ux1.cso.uiuc.edu> <1990Nov26.192218.29782@athena.mit.edu> Organization: AT&T Bell Laboratories Lines: 32 In article <1990Nov26.192218.29782@athena.mit.edu>, scs@adam.mit.edu (Steve Summit) writes: > In article <324@cti1.UUCP> mpledger@cti1.UUCP (Mark Pledger) writes: > >Maybe nobody is reading my question, but everyone keeps mailing me answers > >using sprintf() which is actually what I don't want. ... > Sprintf simply is the recommended function, and it is "fast > enough" in the vast majority of applications. It is the rare > program that can be significantly sped up with a special-purpose > itoa-type routine, and you gave us no indication of why your > program might be one of them. ... I believe very strongly in coding systems to have good performance. But here's a rule of thumb for optimizing code: If you can't say very clearly _why_ you need a faster version of a particular routine, then you probably don't need it. In the cases I can think of (implementation on bare hardware, with no sprintf available; or absolutely performance-critical and the overall algorithm can't be improved instead), knowing _why_ you need it would imply enough knowledge to be able to code it yourself, easily. (Well, maybe if it were a homework assignment and the professor didn't allow you to use sprintf! :-) Anyway, if it's truly performance-critical, you probably need a function tuned to the application: fixed-length strings, or particular distributions of input, or only unsigned, or if all else fails maybe even assembly language. So generic code probably wouldn't do. -- Speaking strictly for myself, -- Lee Derbenwick, AT&T Bell Laboratories, Warren, NJ -- lfd@cbnewsm.ATT.COM or !att!cbnewsm!lfd