Re: Most negative double value

From: Papadopoulos Giannis (ipapadop_at_inf.uth.gr)
Date: 02/24/04


Date: Tue, 24 Feb 2004 03:35:23 +0200

Christian Bau wrote:
> In article <c1bckd$1ffa$1@ulysses.noc.ntua.gr>,
> Papadopoulos Giannis <ipapadop@inf.uth.gr> wrote:
>
>
>>Christian Bau wrote:
>>
>>>The pragmatic solution is to add an appropriate #define into some header
>>>file. Also helpful is to write code that doesn't depend on endianness in
>>>the first place: For example, to write a value x up to 2^32 to a file,
>>>write the bytes (x >> 24) & 0xff, (x >> 16) & 0xff, (x >> 8) & 0xff, x &
>>>0xff and you will get the same results everywhere.
>>
>>Yes, this is right if I am writing robust code to run everywhere... On
>>the other hand this is a really simple (and maybe stupid) program that
>>tries to find machine endianess and is part of my signature...
>>
>>
>>>C doesn't even say that there is such a thing as a "byte ordering": If
>>>for example int has 16 bit, char has 8 bit, and sizeof (int) == 2, then
>>>the 16 bits of an int could be mapped in any possible permutation to the
>>>16 bits in an array of two chars.
>>
>>OK, but all the great minds of processor design have come to the
>>conclusion that the 16bit integer will be represented in either big
>>endian or little endian...
>
>
> comp.lang.c is about portable C. Using non-portable C in your signature
> on comp.lang.c is not too clever.
>

Portable code => good code, but bad logic... :(

>
>>PS even with padding bits, I think *(char*)&v==1 should do the trick...
>>comments?
>
>
> With padding bits, *(char*)&v might read padding bits and nothing else,
> so the result could be anything at all. Of course, if you have padding
> bits then you would have to define what you call "bigendian" and what
> you call "littleendian" first.

Hmmm, I thought all of this and for the time being I do not see a viable
solution... Looking for a new signature already...

-- 
Giannis Papadopoulos
http://dop.users.uth.gr/
University of Thessaly
Computer & Communications Engineering dept.


Relevant Pages

  • Re: Sign w/ BSafe; Verify w/ MS Crypto; Error: Invalid Signature
    ... >> I am getting an error verifying a signature created with BSAFE. ... > other products use big endian byte order. ... > Have you tried reversing the contents of 'signatureKeyData'? ...
    (microsoft.public.platformsdk.security)
  • Re: Verifying Signatures
    ... CryptVerifySignature expects little endian integer. ... complete signature to CryptVerifySignature? ... > Do you know what check comes first, the invalid sig check, or the memory ...
    (microsoft.public.platformsdk.security)
  • Re: Unicode in Visual .NET 2003 and C#
    ... Unicode file will normall have a signature for little endian or big ... I recommend to always use the signature. ...
    (microsoft.public.dotnet.csharp.general)
  • Re: Sign w/ BSafe; Verify w/ MS Crypto; Error: Invalid Signature
    ... >> I am getting an error verifying a signature created with BSAFE. ... > Keep in mind that the CryptoAPI uses little endian byte order and that most ... > other products use big endian byte order. ... > Have you tried reversing the contents of 'signatureKeyData'? ...
    (microsoft.public.platformsdk.security)
  • Re: Most negative double value
    ... Christian Bau wrote: ... > The pragmatic solution is to add an appropriate #define into some header ... endian or little endian... ...
    (comp.lang.c)