This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How convert double type to float?

The time transmitted from ALLSTAR DATA SOURCE is doubletype,and wanted to display time to LCD,so I want to convert double type to float ,and want to uS.How can i do that?
Thanks a lot!

  • How will that help you to display it on an LCD?

    In 'C', a simple assignment will do it - but, If you already have the value as a double, why can't you just display that, and insert any decimal point "manually" as required??

    Remember, the free Evaluation version doesn't do floating point...

  • "How can i do that?"

    Can you provide a link to a document that describes the data output from this device, or provide a better description of it yourself?

    What exactly do you mean when you say 'double' - a 64 bit IEEE binary floating point value, an ASCII representation of a floating point value, or what?

  • "Remember, the free Evaluation version doesn't do floating point..."

    And neither version does double in the commonly assumed 64 bit IEEE format. In C51 a double and a float are both 32 bit.

  • Sorry ,I couldn't described the question clearly at noon.My mean is pointing to 64bits IEEE binary floating point value ,which binary structure as following:

    Double Float (64 bits )
    MSB (bit 63) = Sign
    Bit 62..52 = Exp
    Bit 51..00 = Mantissa
    2exp(-1*bit51) + 2 exp(-2*bit50).......
    Value = Sign * 1.mantissa * 2 exp(EXP-1023)

    Thanks for your help!

  • "My mean is pointing to 64bits IEEE binary floating point value"

    In that case you will have to write your own routine to convert it to a 32 bit IEEE754 float. There is a good description of the 32 bit format on this website - search for IEEE.