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

Using float variable

Hello everyone !

I have a problem with the float variables.

For example, i define float a = 123456123456.1234 and char lcd[30];

I used sprintf function to convert a to string and store into lcd (sprintf(lcd,"%0.2f",a);).

Then, i export lcd to LCD 16x2.

Result i see on the LCD is "123456100000.00"

Why this ?

And can everyone show me how to print a on LCD ("123456123456.1234")?

Best regard !

Parents
  • "do you have any solutions ?"

    As I already suggested:
    "If you want to play with lots of value digits, then you need to play with some form of fixed-point arithmetic - and implement or use a big-number library where the value is stored in an array of bytes or integers."

    You did check the manual, to figure out the size for "float" and "double" data types when using the C51 compiler?

Reply
  • "do you have any solutions ?"

    As I already suggested:
    "If you want to play with lots of value digits, then you need to play with some form of fixed-point arithmetic - and implement or use a big-number library where the value is stored in an array of bytes or integers."

    You did check the manual, to figure out the size for "float" and "double" data types when using the C51 compiler?

Children
No data