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


Groups > alt.comp.lang.borland-delphi > #6418

Re: How to write this sign function in Delphi.

From James Kuyper <jameskuyper@verizon.net>
Newsgroups alt.comp.lang.borland-delphi, alt.comp.lang.c, att.lang.c++, comp.arch, comp.lang.c
Subject Re: How to write this sign function in Delphi.
Date 2015-09-21 19:15 -0400
Organization Self
Message-ID <56008F7B.3030501@verizon.net> (permalink)
References <1315e$5600499f$d47876e2$34602@news.ziggo.nl> <f3842$5600536b$d47876e2$45003@news.ziggo.nl> <MPG.306a4b87db8f8e87989cf8@news.eternal-september.org> <id210btlsqe47v45golbv08mkesillqbnc@4ax.com>

Cross-posted to 5 groups.

Show all headers | View raw


On 09/21/2015 06:51 PM, Robert Wessel wrote:
> On Mon, 21 Sep 2015 18:15:23 -0400, M Philbrook
> <jamie_ka1lpa@charter.net> wrote:
> 
>> In article <f3842$5600536b$d47876e2$45003@news.ziggo.nl>, skybuck2000
>> @hotmail.com says...
>>>
>>> ! in C is supposed to be logical not.
>>>
>>> Not exactly sure what is ment with that... but to me it would seem this 
>>> converts integers to boolean.
>>>
>>> So this could be some kind of integer to boolean conversion operator.
>>>
>>> Perhaps a typecast to boolean might help for Delphi.
>>>
>>> Anyway I also base this on inspecting the assembly a little bit... there was 
>>> a cmp in it... which probably sets some flags...
>>>
>>> and then some kind of set instruction was executed.
>>>
>>> Just for the kick of it here it is:
>>>
>>>
>>> return ((!!x) | (x >> 31));
...
>>
>> I would like to know why you are using double "!!" ?
>>
>> That is a "not" operation and does nothing more than 
>> give you the reverse.
>>
>> Most likely the compiler is ignoring your bad code.
> 
> 
> !! is a common C idiom for reducing a zero/non-zero value to zero/one.

Which doesn't seem particularly useful as the left operand of a
bitwise-or operator in this context.

My best guess is that he thought it mapped zero/non-zero to zero/(-1).
For certain unportable assumptions about how x>>31 works for negative
numbers, that would produce the right result. That would require that he
have serious misconceptions about how the unary ! operator works - but
the words above make it pretty clear that he's pretty much clueless
about such things.

Back to alt.comp.lang.borland-delphi | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-21 20:17 +0200
  Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-21 20:43 +0200
  Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-21 20:53 +0200
  Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-21 20:54 +0200
  Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-21 20:58 +0200
    Re: How to write this sign function in Delphi. M Philbrook <jamie_ka1lpa@charter.net> - 2015-09-21 18:15 -0400
      Re: How to write this sign function in Delphi. Robert Wessel <robertwessel2@yahoo.com> - 2015-09-21 17:51 -0500
        Re: How to write this sign function in Delphi. James Kuyper <jameskuyper@verizon.net> - 2015-09-21 19:15 -0400
          Re: How to write this sign function in Delphi. Robert Wessel <robertwessel2@yahoo.com> - 2015-09-21 23:59 -0500
        Re: How to write this sign function in Delphi. M Philbrook <jamie_ka1lpa@charter.net> - 2015-09-21 22:06 -0400
          Re: How to write this sign function in Delphi. James Kuyper <jameskuyper@verizon.net> - 2015-09-22 10:17 -0400
            Re: How to write this sign function in Delphi. M Philbrook <jamie_ka1lpa@charter.net> - 2015-09-22 19:48 -0400
  Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-21 21:25 +0200
    Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-21 21:54 +0200
    Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-21 22:02 +0200
  Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-21 21:50 +0200
  Re: How to write this sign function in Delphi. M Philbrook <jamie_ka1lpa@charter.net> - 2015-09-21 18:08 -0400
    Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-22 08:31 +0200
  Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-22 10:18 +0200
  Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-22 10:50 +0200
    Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-22 11:00 +0200
    Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-22 11:07 +0200
    Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-22 11:20 +0200
  Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-22 11:15 +0200
    Re: How to write this sign function in Delphi. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-09-22 11:23 +0200

csiph-web