Go to Google Groups Home    comp.lang.c
Expert-Q: (a!=b) != memcmp(&a,&b,sizeof a) ?

alex_krol <alex_k...@scitex.com>

In article <377738B4.97C7...@hls.via.at>,
  Helmut Leitner <leit...@hls.via.at> wrote:

> Let's assume that a and b have the same basic data type
> (e.g. int, long, float, double ...).

> On many platforms it is possible to replace the
> comparisions
>    a==b
>    a!=b
> by
>    memcmp(&a,&b,sizeof(a))==0
>    memcmp(&a,&b,sizeof(a))

> What are the conditions that this will not yield the
> desired results?

   I can think of two:
  a) holes in data type representation
  b) +0 and -0 for one's complement platforms

--
        Regards,
                Alex Krol
Disclaimer: I'm not speaking for Scitex Corporation Ltd

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.