Storing value "200.001"

Hi all,

I am calculating the current height of a spindle motor and then displaying it. The height ranges from "200.999" to "000.001" but I am not sure how to store these values. The float variable can't seem to store anything above 1 digit in the ones column.

Does anyone know how I can store these values?

Thanks very much,

Zeb

ZebH:
Hi all,

I am calculating the current height of a spindle motor and then displaying it. The height ranges from "200.999" to "000.001" but I am not sure how to store these values. The float variable can't seem to store anything above 1 digit in the ones column.

Does anyone know how I can store these values?

Thanks very much,

Zeb

??

Can you illustrate what you mean by the bolded part? Got a code example?

You store it in the format that the program uses. Only translate it to human readable when the human needs to read it.

The float variable can't seem to store anything above 1 digit in the ones column.

Well, whatever you tried may not have worked, but float variables can store 6 decimal digits without losing precision.

For hints on posting, see the "How to use the forum" post.

Hi guys,

According to the Arduino website "Floating-point numbers can be as large as 3.4028235E+38 and as low as -3.4028235E+38".

I thought that it meant you could only have one digit to the left of the decimal point, but it seems I have misunderstood it?

Thanks very much, Zeb

The Arduino website is not completely correct, because it shows eight significant digits. You can plan on six, and often the seventh will also be correct.

Have a read of Scientific notation, which I hope will clarify what 3.4028235E+38 means. It does not mean there can only be one digit to the left of the decimal point.

ZebH:
Hi guys,

According to the Arduino website "Floating-point numbers can be as large as 3.4028235E+38 and as low as -3.4028235E+38".

float - Arduino Reference

I thought that it meant you could only have one digit to the left of the decimal point, but it seems I have misunderstood it?

Thanks very much, Zeb

You have completely misunderstood it. Also this doesn't pass a reality check. Imagine how the hundreds of thousands of Arduino programs that print decimal numbers would be impacted by such a limitation - not possible. Also a simple self written test sketch would give you an answer (and some good programming practice). You didn't even try.

Your question needs more clarity. What is your interest. Is it that you want a fixed decimal place or what? Question is too fuzzy

jremington:
The Arduino website is not completely correct, because it shows eight significant digits. You can plan on six, and often the seventh will also be correct.

IEEE 754 - Wikipedia

Unless you have a board with a 32 bit processor, like many recent ones. Then you get twice as many.

aarg:
Unless you have a board with a 32 bit processor, like many recent ones. Then you get twice as many.

Only if you use a double. A float variable is still 32 bits.