| ??? 09/20/02 07:56 Read: times |
#29418 - Number input from keyboard |
I've got some unvantable, but expectible problem... When I am entering numbers from keyboard, and display them on LCD, I get error like this:
I wanted to enter: 123.9881 but I've got: 123.988099 Software is in C, and looks like that: float form_number(unsigned char new_number) { float whole_number; if(point) // check if point is entered { count_f++; Fractional = Fractional * 10 + new_number; } else integer_part = integer_part*10 + new_number; whole_number = integer_part + Fractional/ (10^count_f); return whole_number; } This is more algorithm, than my original function. I didn't post original because, it has a lot of unnececary things for the quastion I want to ask. So, may be someone knows how to avoid this averanging error? Is it one posibility, simply to display separatly fractional part and integer, without this division: Fractional/ (10^count_f). May be there are more ways??? Thanks in advance! |
| Topic | Author | Date |
| Number input from keyboard | 01/01/70 00:00 | |
| RE: Number input from keyboard | 01/01/70 00:00 | |
| RE: Number input from keyboard | 01/01/70 00:00 | |
| RE: Number input from keyboard | 01/01/70 00:00 | |
| RE: Number input from keyboard | 01/01/70 00:00 | |
| RE: Number input from keyboard | 01/01/70 00:00 | |
| RE: Number input from keyboard | 01/01/70 00:00 | |
| RE: Number input from keyboard | 01/01/70 00:00 | |
RE: Number input from keyboard | 01/01/70 00:00 |



