From: io_x on

"io_x" <a(a)b.c.invalid> ha scritto nel messaggio
news:4bec39a4$0$18987$4fafbaef(a)reader5.news.tin.it...
>> while(!(*((int16_t*) &CorrValue + 1) < 0)) // MS_Bit = 0


is it not far better to write:

int16_t *CorrValue2Arr=(int16_t ) &CorrValue;
while(CorrValue2Arr[1]>=0) // MS_Bit == signBit == 0
{}
?

> the problem i have here: !*a<0 means !(*a<0), or it means ((!*a)<0)?
> i think it is the second one
> if it is the second one !*a could be 0 (0<0 false) or 1 (1<0 false)
> so this while is always false (no iteration)
>
> you people get wrong when the over think for the C language grammar,
> get you to lost the think on the problem to resolve :)






From: io_x on

"io_x" <a(a)b.c.invalid> ha scritto nel messaggio
news:4bec3df9$0$12123$4fafbaef(a)reader4.news.tin.it...
>
> "io_x" <a(a)b.c.invalid> ha scritto nel messaggio
> news:4bec39a4$0$18987$4fafbaef(a)reader5.news.tin.it...
>>> while(!(*((int16_t*) &CorrValue + 1) < 0)) // MS_Bit = 0
>
>
> is it not far better to write:
>
> int16_t *CorrValue2Arr=(int16_t ) &CorrValue;

wrong arghhaahah

int16_t *CorrValue2Arr=(int16_t*) &CorrValue;

while(CorrValue2Arr[1]>=0)// MS_Bit==signBit(CorrValue2Arr[1])==0
{}
> ?
>
>> the problem i have here: !*a<0 means !(*a<0), or it means ((!*a)<0)?
>> i think it is the second one
>> if it is the second one !*a could be 0 (0<0 false) or 1 (1<0 false)
>> so this while is always false (no iteration)
>>
>> you people get wrong when the over think for the C language grammar,
>> get you to lost the think on the problem to resolve :)
>
>
>
>
>
>



From: Steve Pope on
io_x <a(a)b.c.invalid> wrote:

>"Jason" <cincydsp(a)gmail.com> ha scritto nel messaggio

>> while(!(*((int16_t*) &CorrValue + 1) < 0)) // MS_Bit = 0

>the problem i have here: !*a<0 means !(*a<0), or it means ((!*a)<0)?
>i think it is the second one

If means ((!*a) < 0), since ! and * have precedence over <; which means
specifically ((!(*a)) < 0). (Prefix operators of the same precedence,
such as ! and *, associate right to left.)


Steve
From: Ben Bacarisse on
"io_x" <a(a)b.c.invalid> writes:

> "Jason" <cincydsp(a)gmail.com> ha scritto nel messaggio
> news:87ef5391-d194-4e7c-908e-3af03868b5ca(a)h39g2000yqn.googlegroups.com...
> On May 13, 10:00 am, narke <narkewo...(a)gmail.com> wrote:
<snip>
>> while(!(*((int16_t*) &CorrValue + 1) < 0)) // MS_Bit = 0
>
> the problem i have here: !*a<0 means !(*a<0), or it means ((!*a)<0)?
> i think it is the second one

!*a<0 means (!*a) < 0 but that is not what was written. The ! is
outside a fully parenthesised relational expression:

!(E < 0) or E >= 0

By the way, I agree entirely with your re-write (in a subsequent post).
Using array notation is much clearer:

int16_t *half_word = (void *)&CorrValue;
while (half_word[1] >= 0) ...

however this still confuses significance with address order (i.e. it
assumes endianness).

<snip>
--
Ben.
From: Steve Pope on
Ben Bacarisse <ben.usenet(a)bsb.me.uk> wrote:

>!*a<0 means (!*a) < 0 but that is not what was written. The ! is
>outside a fully parenthesised relational expression:
>
> !(E < 0) or E >= 0
>
>By the way, I agree entirely with your re-write (in a subsequent post).
>Using array notation is much clearer:
>
> int16_t *half_word = (void *)&CorrValue;
> while (half_word[1] >= 0) ...
>
>however this still confuses significance with address order (i.e. it
>assumes endianness).

Tangentially, there are these nice things called log functions
in the math libraries that can be used for leading zero counts.

It is (usually) no longer necessary to worry about library functions
being too slow and hand-coding this stuff...

Steve