On Mon, 19 Oct 2015 15:32:00 +0200, Jonas Maebe <jonas.ma...@elis.ugent.be> wrote:
> >Bo Berglund wrote on Mon, 19 Oct 2015: > >> Is there a function or such to interrogate the byte order of the >> platform FPC runs on? So that I could add a test at the start of >> download to check if swapping is needed? > >Use the http://www.freepascal.org/docs-html/rtl/system/ntobe.html >function and you don't have to care about what your host platform uses. > This sounds OK were it not for the fact that it has overloaded implementations for: Smallint, Word, LongInt, DWord, Int64, QWord. I need to convert not only integer types but also single precision floats. These are the main part of the data. But I have found that I can make an endian test like this: function PCEndian: boolean; var sTest: string fTest: single; begin sTest := #0#0#$20#$40; Move(sTest[1], fTest, 4); Result := Abs(fTest - 2.5) < 0.01; end; Single precision value with hex representation 40200000 is 1.1569E-41 on a PC but 00002040 is exactly 2.5. -- Bo Berglund Developer in Sweden _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal