Re: Leading Zeros? (question rephrased)
- To: mathgroup at smc.vnet.net
- Subject: [mg54493] Re: [mg54378] Leading Zeros? (question rephrased)
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Tue, 22 Feb 2005 04:22:52 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
>-----Original Message----- >From: AES [mailto:siegman at stanford.edu] To: mathgroup at smc.vnet.net >Sent: Saturday, February 19, 2005 8:33 AM >To: mathgroup at smc.vnet.net >Subject: [mg54493] [mg54378] Leading Zeros? (question rephrased) > >Thanks for a couple of private msgs in response to my earlier >post, but my question is not how to format or display numbers >with leading zeros. > >Instead I'm asking, suppose I type > > y = {001,002,003}; > >into a newly opened "virgin" instance of Mathematica, without >defining any special formats or rules before I do this. > >Are the leading zeros that I type into this list captured and >stored somehow by Mathematica? > >Or is the default response that they're ignored and lost >forever? (As I believe they are.) > >------------- > >P.S. -- I'm not trying to argue what Mathematica should do, >either way. >I'm just trying to learn whether Mathematica in particular, or >mathematics or computer science generally, has any "official policies" >on capturing or storing leading zeros that a user may type in, >or that may be loaded into a database. > >The question arises in part because there's a scientific >journal that identifies articles by "article numbers" rather >than page numbers, with the initial digit of the article >number sometimes being zero and sometimes non-zero, and the >zero when it's present being mandatory (at least for some >purposes). This number, moreover, is treated for some >purposes as a numerical value, though it's obviously also in >some ways a "text label" rather than a numerical value. > >Seem to me this is not a particularly wise design decision >(although it's the case for ZIP codes also), and I'm wondering >if there's any computer science thinking on it.] > > Dear Professor Siegman, Input conversion is done (in part) already by the front end, as you can see from In[3]:= ToBoxes[001] Out[3]= "1" After parsing, the number itself, in any case, will have no leading zeroes In[1]:= MakeExpression["001"] Out[1]= HoldComplete[1] In fact, the pure notion of "leading zeros" isn't a property of numbers, but of number representation. Now for second question: if "numbers" are used for classification or as identifiers you have to watch out for each case in particular: it is not uncommon that not numbers, integers that is, but strings are used and stored in the database. In fact this is one of the first questions the analyst has to clarify. Just recently, here in Germany, we have had a million-$-bug, because for Hartz IV data entry bank account numbers were padded to the left by the innocent (and stupid BTW) acquisition software. Deplorably some programming languages (typically script languages) blur the destinction between numbers and their string representations, which often might be convenient, but also the cause of errors. -- Hartmut Wolf