Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #3526 > unrolled thread

char to decimal

Started byDirk Bruere at NeoPax <dirk.bruere@gmail.com>
First post2011-05-05 01:43 +0100
Last post2011-05-05 16:15 +0100
Articles 20 on this page of 76 — 19 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  char to decimal Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-05-05 01:43 +0100
    Re: char to decimal Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2011-05-04 17:49 -0700
    Re: char to decimal Ian Shef <invalid@avoiding.spam> - 2011-05-05 01:06 +0000
      Re: char to decimal Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-05 20:03 +1200
        Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-05 07:03 -0400
          Re: char to decimal Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-05 11:18 +0000
            Re: char to decimal Patricia Shanahan <pats@acm.org> - 2011-05-05 06:11 -0700
              Re: char to decimal Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-06 01:59 +1200
                Re: char to decimal Mayeul <mayeul.marguet@free.fr> - 2011-05-05 16:53 +0200
                  Re: char to decimal Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-06 11:49 +1200
                    Re: char to decimal Mayeul <mayeul.marguet@free.fr> - 2011-05-06 08:46 +0200
                      Re: char to decimal Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-06 18:43 +1200
                        Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-06 06:52 -0400
                          Re: char to decimal Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-06 11:39 +0000
                Re: char to decimal Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-05-05 14:13 -0400
                  Re: char to decimal Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-06 11:49 +1200
                    Re: char to decimal Mayeul <mayeul.marguet@free.fr> - 2011-05-06 08:47 +0200
                      Re: char to decimal Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-06 18:43 +1200
                        Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-06 06:54 -0400
                      Re: char to decimal Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-05-06 10:30 +0300
                Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-05 17:05 -0400
              Re: char to decimal Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-05 14:56 +0000
                Re: char to decimal Paul Cager <paul.cager@googlemail.com> - 2011-05-05 11:48 -0700
                  Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-05 17:06 -0400
                  Re: char to decimal Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-05 21:28 +0000
                    Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-05 17:32 -0400
                      Re: char to decimal Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-06 08:31 +0000
            Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-05 17:04 -0400
        boolean to int : was char to decimal Jeff Higgins <jeff@invalid.invalid> - 2011-05-06 09:00 -0400
          Re: boolean to int : was char to decimal Patricia Shanahan <pats@acm.org> - 2011-05-06 06:54 -0700
          Re: boolean to int : was char to decimal markspace <-@.> - 2011-05-06 07:07 -0700
            Re: boolean to int : was char to decimal markspace <-@.> - 2011-05-06 08:30 -0700
          Re: boolean to int : was char to decimal Nigel Wade <nmw-news@ion.le.ac.uk> - 2011-05-06 15:35 +0100
          Re: boolean to int : was char to decimal Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-06 19:12 +0200
          Re: boolean to int : was char to decimal Jeff Higgins <jeff@invalid.invalid> - 2011-05-06 13:26 -0400
            Re: boolean to int : was char to decimal Jeff Higgins <jeff@invalid.invalid> - 2011-05-06 21:25 -0400
            Re: boolean to int : was char to decimal Jeff Higgins <jeff@invalid.invalid> - 2011-05-06 21:28 -0400
            Re: boolean to int : was char to decimal Michael Wojcik <mwojcik@newsguy.com> - 2011-05-09 12:51 -0400
              Re: boolean to int : was char to decimal Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-09 23:54 +0000
              Re: boolean to int : was char to decimal Jeff Higgins <jeff@invalid.invalid> - 2011-05-09 20:51 -0400
                Re: boolean to int : was char to decimal Michael Wojcik <mwojcik@newsguy.com> - 2011-05-10 11:20 -0400
                Re: boolean to int : was char to decimal Jeff Higgins <jeff@invalid.invalid> - 2011-06-23 07:26 -0400
                  Re: boolean to int : was char to decimal Roedy Green <see_website@mindprod.com.invalid> - 2011-06-23 10:07 -0700
                    Re: boolean to int : was char to decimal bugbear <bugbear@trim_papermule.co.uk_trim> - 2011-06-24 09:51 +0100
              Re: boolean to int : was char to decimal Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-10 13:47 +1200
                Re: boolean to int : was char to decimal Michael Wojcik <mwojcik@newsguy.com> - 2011-05-10 11:02 -0400
                  Re: boolean to int : was char to decimal Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-11 14:05 +1200
                    Re: boolean to int : was char to decimal Jeff Higgins <jeff@invalid.invalid> - 2011-05-11 08:11 -0400
    Re: char to decimal Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-05-05 02:12 +0100
    Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-04 21:59 -0400
      Re: char to decimal Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-05-05 16:14 +0100
        Re: char to decimal markspace <-@.> - 2011-05-05 11:20 -0700
          Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-05 17:10 -0400
            Re: char to decimal Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-05 22:00 +0000
              Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-05 18:20 -0400
            Re: char to decimal Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-05-06 10:45 +0100
              Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-06 06:56 -0400
                Re: char to decimal Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-06 11:48 +0000
                  Re: char to decimal Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-05-06 08:38 -0400
                  Re: char to decimal Michael Wojcik <mwojcik@newsguy.com> - 2011-05-06 09:47 -0400
                    Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-06 12:02 -0400
                    Re: char to decimal Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-06 19:15 +0200
                      Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-06 14:01 -0400
                        Re: char to decimal Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-06 20:07 +0200
                          Re: O/T linguistics (Was: char to decimal) Lew <noone@lewscanon.com> - 2011-05-06 15:28 -0400
                            Re: O/T linguistics Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-06 21:44 +0200
                          Re: char to decimal Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-06 23:57 +0000
                  Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-06 12:00 -0400
                Re: char to decimal Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-05-06 18:29 +0100
                  Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-06 14:02 -0400
                    Re: char to decimal Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-05-07 01:09 +0100
                    Re: char to decimal Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-07 00:18 +0000
                      Re: char to decimal Lew <noone@lewscanon.com> - 2011-05-06 21:30 -0400
    Re: char to decimal Roedy Green <see_website@mindprod.com.invalid> - 2011-05-04 22:03 -0700
      Re: char to decimal "Nasser M. Abbasi" <nma@12000.org> - 2011-05-05 01:14 -0700
      Re: char to decimal Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-05-05 16:15 +0100

Page 1 of 4  [1] 2 3 4  Next page →


#3526 — char to decimal

FromDirk Bruere at NeoPax <dirk.bruere@gmail.com>
Date2011-05-05 01:43 +0100
Subjectchar to decimal
Message-ID<92ea64F3avU1@mid.individual.net>
IU need to take a char in UTF-8 and convert it to an ascii int (decimal)

eg "a" = 97

which is then converted to the string "97"
Is there a simple way to do this?

-- 
Dirk

http://www.neopax.com/technomage/ - My new book - Magick and Technology

[toc] | [next] | [standalone]


#3527

FromKnute Johnson <nospam@rabbitbrush.frazmtn.com>
Date2011-05-04 17:49 -0700
Message-ID<Oumwp.15099$_P6.3640@newsfe05.iad>
In reply to#3526
On 5/4/2011 5:43 PM, Dirk Bruere at NeoPax wrote:
> IU need to take a char in UTF-8 and convert it to an ascii int (decimal)
>
> eg "a" = 97
>
> which is then converted to the string "97"
> Is there a simple way to do this?
>

You can cast it to a short.

-- 

Knute Johnson
s/knute/nospam/

[toc] | [prev] | [next] | [standalone]


#3528

FromIan Shef <invalid@avoiding.spam>
Date2011-05-05 01:06 +0000
Message-ID<Xns9EDBB8224D5B6vaj4088ianshef@138.125.254.103>
In reply to#3526
Dirk Bruere at NeoPax <dirk.bruere@gmail.com> wrote in news:92ea64F3avU1
@mid.individual.net:

> IU need to take a char in UTF-8 and convert it to an ascii int (decimal)
> 
> eg "a" = 97
> 
> which is then converted to the string "97"
> Is there a simple way to do this?
> 

Yes.  The details depend upon what you really meant.  Here are two ways:


public class CharToDecimal {
  public static void main(String[] args) {
    char c = 'a' ;
    System.out.println((int)c) ;     // Directly output the string.
    String s = Integer.toString(c) ; // Create a String without output.
    System.out.println(s);           // Output the String for verification.
  }
}

A char is much like an int except that:

It has 16 bits instead of 32.
It is unsigned, with a value from 0 through 65535.
It gets special handling in some places, such as by System.out.println.  The 
special handling by System.out.println can be avoided by casting to an int.

[toc] | [prev] | [next] | [standalone]


#3545

FromLawrence D'Oliveiro <ldo@geek-central.gen.new_zealand>
Date2011-05-05 20:03 +1200
Message-ID<iptlkq$62g$2@lust.ihug.co.nz>
In reply to#3528
In message <Xns9EDBB8224D5B6vaj4088ianshef@138.125.254.103>, Ian Shef wrote:

> A char is much like an int except that:
> 
> It has 16 bits instead of 32.
> It is unsigned, with a value from 0 through 65535.
> It gets special handling in some places, such as by System.out.println. 
> The special handling by System.out.println can be avoided by casting to an
> int.

Funny, they could do all this for char, but not for boolean.

[toc] | [prev] | [next] | [standalone]


#3551

FromLew <noone@lewscanon.com>
Date2011-05-05 07:03 -0400
Message-ID<ipu045$6mn$1@news.albasani.net>
In reply to#3545
Lawrence D'Oliveiro wrote:
> Ian Shef wrote:
>
>> A char is much like an int except that:
>>
>> It has 16 bits instead of 32.
>> It is unsigned, with a value from 0 through 65535.
>> It gets special handling in some places, such as by System.out.println.
>> The special handling by System.out.println can be avoided by casting to an
>> int.
>
> Funny, they could do all this for char, but not for boolean.

Booleans are not numbers.  There's nothing funny about that choice at all.  As 
you well know, having been down this road before.

-- 
Lew
Awaiting the inevitable now.

[toc] | [prev] | [next] | [standalone]


#3554

FromAndreas Leitgeb <avl@gamma.logic.tuwien.ac.at>
Date2011-05-05 11:18 +0000
Message-ID<slrnis51su.phi.avl@gamma.logic.tuwien.ac.at>
In reply to#3551
Lew <noone@lewscanon.com> wrote:
> Lawrence D'Oliveiro wrote:
>> Ian Shef wrote:
>>> A char is much like an int except that:
>>> It has 16 bits instead of 32.
>>> It is unsigned, with a value from 0 through 65535.
>>> It gets special handling in some places, such as by System.out.println.
>>> The special handling by System.out.println can be avoided by casting to an
>>> int.
>> Funny, they could do all this for char, but not for boolean.
> Booleans are not numbers.

But characters are.  So, 'a' is just as naturally 97 as true isn't 1

[toc] | [prev] | [next] | [standalone]


#3557

FromPatricia Shanahan <pats@acm.org>
Date2011-05-05 06:11 -0700
Message-ID<9pednRnBeuxtPF_QnZ2dnUVZ_uGdnZ2d@earthlink.com>
In reply to#3554
On 5/5/2011 4:18 AM, Andreas Leitgeb wrote:
> Lew<noone@lewscanon.com>  wrote:
>> Lawrence D'Oliveiro wrote:
>>> Ian Shef wrote:
>>>> A char is much like an int except that:
>>>> It has 16 bits instead of 32.
>>>> It is unsigned, with a value from 0 through 65535.
>>>> It gets special handling in some places, such as by System.out.println.
>>>> The special handling by System.out.println can be avoided by casting to an
>>>> int.
>>> Funny, they could do all this for char, but not for boolean.
>> Booleans are not numbers.
>
> But characters are.  So, 'a' is just as naturally 97 as true isn't 1
>

I would phrase it slightly differently. 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, especially considering the fact that
the smallest integer type in Java has 256 different values, and Boolean
only has two.

Patricia

[toc] | [prev] | [next] | [standalone]


#3559

FromLawrence D'Oliveiro <ldo@geek-central.gen.new_zealand>
Date2011-05-06 01:59 +1200
Message-ID<ipuagg$iho$1@lust.ihug.co.nz>
In reply to#3557
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.

[toc] | [prev] | [next] | [standalone]


#3560

FromMayeul <mayeul.marguet@free.fr>
Date2011-05-05 16:53 +0200
Message-ID<4dc2b864$0$1468$426a74cc@news.free.fr>
In reply to#3559
On 05/05/2011 15:59, 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.

Says who?

#1
true => 0
false => 1

#2
true => 1
false => 0

#3
true => 1
false => 2

#4
true => 2
false => 1

#5
true => 1
false => -1

#6
true => -1
false => 1

--
Mayeul

[toc] | [prev] | [next] | [standalone]


#3626

FromLawrence D'Oliveiro <ldo@geek-central.gen.new_zealand>
Date2011-05-06 11:49 +1200
Message-ID<ipvd27$6ec$2@lust.ihug.co.nz>
In reply to#3560
In message <4dc2b864$0$1468$426a74cc@news.free.fr>, Mayeul wrote:

> On 05/05/2011 15:59, 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.
> 
> Says who?

Most reasonably-designed programming languages.

[toc] | [prev] | [next] | [standalone]


#3641

FromMayeul <mayeul.marguet@free.fr>
Date2011-05-06 08:46 +0200
Message-ID<4dc397a8$0$8415$426a74cc@news.free.fr>
In reply to#3626
On 06/05/2011 01:49, Lawrence D'Oliveiro wrote:
> In message<4dc2b864$0$1468$426a74cc@news.free.fr>, Mayeul wrote:
>
>> On 05/05/2011 15:59, 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.
>>
>> Says who?
>
> Most reasonably-designed programming languages.

I was unaware that any programmaing language, reasonable or not, had 
"strong natural association" in mind when deciding on the rules of their 
boolean/integer conversion rules.

That might be because they never had.

--
Mayeul

[toc] | [prev] | [next] | [standalone]


#3644

FromLawrence D'Oliveiro <ldo@geek-central.gen.new_zealand>
Date2011-05-06 18:43 +1200
Message-ID<iq059t$jpv$3@lust.ihug.co.nz>
In reply to#3641
In message <4dc397a8$0$8415$426a74cc@news.free.fr>, Mayeul wrote:

> On 06/05/2011 01:49, Lawrence D'Oliveiro wrote:
>
>> In message<4dc2b864$0$1468$426a74cc@news.free.fr>, Mayeul wrote:
>>
>>> On 05/05/2011 15:59, 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.
>>>
>>> Says who?
>>
>> Most reasonably-designed programming languages.
> 
> I was unaware that any programmaing language, reasonable or not, had
> "strong natural association" in mind when deciding on the rules of their
> boolean/integer conversion rules.
> 
> That might be because they never had.

Or simply that you are unaware.

[toc] | [prev] | [next] | [standalone]


#3665

FromLew <noone@lewscanon.com>
Date2011-05-06 06:52 -0400
Message-ID<iq0jsa$29b$1@news.albasani.net>
In reply to#3644
Lawrence D'Oliveiro wrote:
> Or simply that you are unaware.

To simply put out snarky indirect and unsupportable crap does not constitute 
conversation.  Are you afraid to put out statements of fact, reason or logic, 
remembering what happened last time you tried to claim a "natural" association 
between "true" and some number?  You were simply overwhelmed by well 
though-out theses that contradicted yours.  Is that why you won't offer a 
SINGLE point of logic, instead confining yourself to vague, oracular 
pronouncements as if you hoped to convince someone that you've actually had a 
thought?

As for that particular remark, you are most definitely the pot calling the 
kettle black.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

[toc] | [prev] | [next] | [standalone]


#3673

FromAndreas Leitgeb <avl@gamma.logic.tuwien.ac.at>
Date2011-05-06 11:39 +0000
Message-ID<slrnis7nes.phi.avl@gamma.logic.tuwien.ac.at>
In reply to#3665
Lew <noone@lewscanon.com> wrote [towards Lawrence]:
> You were simply overwhelmed by well though-out [sic] theses ...

Good joke :-D   ymmd!

[toc] | [prev] | [next] | [standalone]


#3575

FromJoshua Cranmer <Pidgeot18@verizon.invalid>
Date2011-05-05 14:13 -0400
Message-ID<ipupce$p2k$1@dont-email.me>
In reply to#3559
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. If you dislike 
the middle one, think about signs of non-zero numbers.

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth

[toc] | [prev] | [next] | [standalone]


#3627

FromLawrence D'Oliveiro <ldo@geek-central.gen.new_zealand>
Date2011-05-06 11:49 +1200
Message-ID<ipvd35$6ec$3@lust.ihug.co.nz>
In reply to#3575
In message <ipupce$p2k$1@dont-email.me>, 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.

[toc] | [prev] | [next] | [standalone]


#3643

FromMayeul <mayeul.marguet@free.fr>
Date2011-05-06 08:47 +0200
Message-ID<4dc39812$0$8415$426a74cc@news.free.fr>
In reply to#3627
On 06/05/2011 01:49, Lawrence D'Oliveiro wrote:
> In message<ipupce$p2k$1@dont-email.me>, 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?

--
Mayeul

[toc] | [prev] | [next] | [standalone]


#3645

FromLawrence D'Oliveiro <ldo@geek-central.gen.new_zealand>
Date2011-05-06 18:43 +1200
Message-ID<iq05ai$jpv$4@lust.ihug.co.nz>
In reply to#3643
In message <4dc39812$0$8415$426a74cc@news.free.fr>, Mayeul wrote:

> On 06/05/2011 01:49, Lawrence D'Oliveiro wrote:
>
>> In message<ipupce$p2k$1@dont-email.me>, 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?

I gave some examples previously—go look them up.

[toc] | [prev] | [next] | [standalone]


#3666

FromLew <noone@lewscanon.com>
Date2011-05-06 06:54 -0400
Message-ID<iq0k07$29b$2@news.albasani.net>
In reply to#3645
Lawrence D'Oliveiro wrote:
> I gave some examples previously—go look them up.

We completely refuted your stupid points previously.  You are really a troll!

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

[toc] | [prev] | [next] | [standalone]


#3647

FromJussi Piitulainen <jpiitula@ling.helsinki.fi>
Date2011-05-06 10:30 +0300
Message-ID<qotsjssmglj.fsf@ruuvi.it.helsinki.fi>
In reply to#3643
Mayeul writes:
> On 06/05/2011 01:49, Lawrence D'Oliveiro wrote:
> > In message<ipupce$p2k$1@dont-email.me>, 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.

[toc] | [prev] | [next] | [standalone]


Page 1 of 4  [1] 2 3 4  Next page →

Back to top | Article view | comp.lang.java.programmer


csiph-web