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

Float data type!!

HI!!
8051 microcontroller dont support float data type.
How can I implement a float function???

Thanks

Parents Reply Children
  • I have no error because im not implemented this float function.

    So you haven't even tried using a float datatype because you "know" that it will not work ?

    Did you read the description of the C51 compiler ?

    http://www.keil.com/c51/c51.asp

    8051 manual say that this micro canÂ't do float operation.<p>

    What the microcontroller can or cannot do it entirely irrelevant when you are using a compiler. The compiler is free to use appropriate libraries to do all the things that the underlying processor cannot do in hardware. It might, however, take a lot of CPU cycles to do all of that in software.

    The 8051 also "cannot" do 16- and 32-bit integer arithmetics, and yet the compiler can offer int and long datatypes.

    My question is if there is any way to do it??

    Yes. You can use the compiler's floating point libraries (simply use float datatypes, the compiler will know what to do), or you can roll your own floating-point libraries in assembly. It's not rocket science, but about as useful as reinventing the wheel.

    And as always, floating point math does not give you a higher resolution than integer math with the same number of bits (32 bits can only hold 2^32 different values - no data type can change anything about that). It gives you a larger range at the cost of adapting the resolution to the absolute value of the variable, with all the strange effects this will cause.