Using sdfat to write short floats to SD card

Hi, I am hoping to using SDfat (or any other reasonably fast way) to write a short float (i.e. 16-bit) to a SD card logger in Hex (i.e. as a 2 byte hex). I am struggling to find a way. The AnalogBinLogger example in SDfat seems to do it, but I really can't see how.

Any suggestions?

A 2 byte hex value is only a byte. One byte for each hex digit. Did you mean a 4 digit hex value? Are you writing to the file in ASCII or binary?

Sorry I am probably confusing my terminology. I would like to write in binary.

Where the floating point number would be represented by 4 hex values (2 bytes?) i.e. e9 03 da 03

= float 1.2813786e-036.

So essentially I want to be able to take a number in the Arduino (e.g. 1.2813786e-036) and write a binary number to the SD card (i.e . e9 03 da 03).

Cheers, T

16 bit float is not supported. You will have to write your own code or find a library to do it (good luck with that). If you're asking how to code it, you would have to go and look at the storage formats and implement them.

If you already have done that, and simply wish to know how to write it as bytes to the SD file, it's often done with unions.

Or have you done neither?

I am afraid neither. I have done quite a bit of Matlab/Fortran coding, but sadly almost no C. So just learning.

If 16-bit ints are supported, that would be fine (and easier to write out). I am looking to express speeds etc from -100 to 100 m/s with 2 decimal places. So I can just change units to cm/s and work with ints.