Re: How to byte swap an IEEE Float?



> Sure. You know, I meant representation = bits and bytes, implying same
> length. It seems the OP already has the float type (IEEE_Float_32),
> 32-bit = 4-byte long, and the data are floats of this length, only
> different in byte order.
>
> OP, if the data are of a different length, then you have to unchecked
> convert first to a float type of that length, and then normal convert
> to the final type (risking Constraint_Error).

All the data in the file are of 32 bits float so that should be ok.
The target for the values is at the moment x86 (although I do expect it
to work on PowerPC as well so I check System.Default_Bit_Order before
doing any byte swapping). My dirty workaround for the moment was to
read the data as a string. I was merly wondering which is the
normal/"best" way to deal with this, since I expect it to be a
fairly common task. A packed byte array does however seem like a much
better idea than handling it as a string.

Regards
Björn

.



Relevant Pages

  • Re: weird problem
    ... I already told you that the comparison between an integer and a float ... to strcmpwhich expects a pointer to a string. ... And now a question about something else: why do you use floating ... int,float, char, etc. ...
    (comp.lang.c)
  • Re: inconsistent behavior of >FLOAT
    ... empty string, strings with leading and trailing blanks. ... I think it is too late for>FLOAT to rescind the strong suggestion in its spec that this "should" be the case. ... As long as the spec is tightened to require that a string of blanks must be treated as a valid zero, a programmer would know to filter such a case, if needed, before it is passed to>FLOAT. ... I think ignoring leading and trailing blanks may be reasonable for>FLOAT, as long as it does not violate the current spec. ...
    (comp.lang.forth)
  • Re: weird problem
    ... I already told you that the comparison between an integer and a float ... And now a question about something else: why do you use floating ... use then to copy a float into a char *1. ... binary representation doesn't resemble a string like "123.46343" ...
    (comp.lang.c)
  • Re: How to marshall "pointer to pointer"
    ... UInt16 Layer, ByteInstanceName, float X, float Y, BytePath, IntPtr ... DstPath); ... IntPtr and pass it it Marshal.PtrToStringBSTR() to get this string. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: help with Table Macro
    ... Available Float, which will always be in column ... string contained in that cell. ... test phrase "available float". ... next matching word and repeat the process until no more matching words ...
    (microsoft.public.word.application.errors)