Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!goblin1!goblin3!goblin.stu.neva.ru!newsfeed2.funet.fi!newsfeeds.funet.fi!news.cc.tut.fi!news.helsinki.fi!.POSTED!not-for-mail From: Jussi Piitulainen Newsgroups: comp.lang.java.programmer Subject: Re: char to decimal Date: 06 May 2011 10:30:00 +0300 Organization: University of Helsinki Lines: 44 Sender: jpiitula@ruuvi.it.helsinki.fi Message-ID: References: <92ea64F3avU1@mid.individual.net> <9pednRnBeuxtPF_QnZ2dnUVZ_uGdnZ2d@earthlink.com> <4dc39812$0$8415$426a74cc@news.free.fr> NNTP-Posting-Host: ruuvi.it.helsinki.fi Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: oravannahka.helsinki.fi 1304667000 10185 128.214.205.65 (6 May 2011 07:30:00 GMT) X-Complaints-To: usenet@oravannahka.helsinki.fi NNTP-Posting-Date: Fri, 6 May 2011 07:30:00 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3647 Mayeul writes: > On 06/05/2011 01:49, Lawrence D'Oliveiro wrote: > > In message, Joshua Cranmer wrote: > > > >> On 05/05/2011 09:59 AM, Lawrence D'Oliveiro wrote: > >> > >>> In message<9pednRnBeuxtPF_QnZ2dnUVZ_uGdnZ2d@earthlink.com>, Patricia > >>> Shanahan wrote: > >>> > >>>> There is a strong natural association between a character and the > >>>> numeric value of its Unicode representation. There are several different > >>>> ways of mapping between the two Boolean values and integers ... > >>> > >>> Only one “strong natural association”, though. > >> > >> 0,1; 1, -1; and 0, -1 all have arguments for their use. > > > > One of them is more useful than the others. > > Says who, which one, on what grounds, and what do you make of the swaps? Graham, Knuth, Patashnik, in Concrete Mathematics: A Foundation for Computer Science, use [S] to stand for 0 when S is a false statement and for 1 one when S is a true statement. They attribute the notation to Iverson, who used round brackets. They find the mapping useful. For example, the sign of x is [x > 0] - [x < 0]. For example, to add 1 to f(x) if n is divisible by m, you could write f(x) + [n mod m > 0]. (In Java, use the per cent operator to get the canonical element that is congruent to n modulo m.) A widely used special case in mathematics is so called Kronecker's delta that stands for [x = y]. (That's equality, not assignment.) You get the other mappings quoted above as 1 - 2*[S] and -[S]. And whatever the two hash values were, call them F and T, you could get them as F*[not s] + T*[s] where s is the truth value of the statement S. (In Java, write !s for not s, I think.) I am not saying that Java should do anything about all this. I am saying that one of the mappings is already in general use elsewhere, with established notations for it.