floating point representation .

my program generates floating point values , and they need to be stored in an SD card in
a 32bit IEEE format . i did look up the format and the conversion method , it's not that hard but it's very consuming of CPU power , and my program needs to be relatively fast (floating point calculations are too slow as they are , conversion would consume a lot more time) . how are Floating point variables stored in RAM on arduino boards ? if it's already on the IEEE 32bit form how can i access the bytes as they are to store them on the SD card ?

thank you very much .

It's just four bytes; store it as four bytes and read it back as four bytes.

will this work ? :

write_float      (File sdf , float f)
 
    {    for(byte a=0;a<4;a++)  sdf.write(*(&f+a));  }

will this work ? :

The beauty of Arduino is that you could have tried it and had the answer in the time it took you to write the post and wait for a response.

No, it won't work. Pointer arithmetic considers the size of the object being pointed to. Adding 1 to a float * will move 4 bytes along in the memory.

Cast it to a byte * before doing the addition. Look at the examples for writing multi-byte variables to EEPROM.

Cast it to a byte *

 file.write((uint8_t*)&myFloat, 4);

What are you planning to do with an SD card full of binary IEEE float values? How are you planning to access and analyse the data?

cattledog:

 file.write((uint8_t*)&myFloat, 4);

What are you planning to do with an SD card full of binary IEEE float values? How are you planning to access and analyse the data?

thank you very much .
i am working on a 3D scanner , i want the arduino to export stl files to the sd card .

i want the arduino to export stl files to the sd card .

Have you looked at an stl file? They are usually text files.