![]() |
Printing floats.
Having troubles working with float varibles, we're trying to solve the problems, but $f doesn't print float varibles.
If not, then how? |
Re: Printing floats.
Read the docs for the C compiler/C library. Floating point format is not supported in the C18 printf.
You can roll your own if you know the range of values (like between .01 and 99.99) by converting to a fixed point integer for example, or by just using fixed point arithmatic instead of float or double. For example, we have PID factors that are 0.00 to 9.99 in range using fixed point; something like correction = (p * proportion)/100; and proportation is a signed int in the range of 0..999 which represents 0.00 to 9.99 as previously stated. I use the following to convert proportion to a friendly output value. I don't have to worry about sign since it is always positive by design. Just an example. Code:
|
| All times are GMT -5. The time now is 04:47. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi