View previous topic :: View next topic |
Author |
Message |
Guest1111 Guest
|
Another bisarre float behavoir |
Posted: Thu Sep 27, 2007 8:09 am |
|
|
The below code show -1912.492032 (LCD module)
but it's correctly memory stored (inspecting it with the debugger)
PCHW 3.249
any aidea?
Code: | #include <18f452.h>
#fuses HS, NOWDT, PUT, NOLVP, BORV27, NOPROTECT, CCP2B3
/* frecuencia del cristal del sistema */
#use delay(clock=10000000)
#include <lcd.h>
main()
{
float a = 2382.465;
lcd_init();
printf(lcd_putc,"%f",a);
while(TRUE);
}
|
|
|
|
Ttelmah Guest
|
|
Posted: Thu Sep 27, 2007 8:27 am |
|
|
Simple answer.
This is a 'known' bug with using %f, without a width specifier. Has been discussed here many times. Just limit the output width (so something like %6.3f), and it'll work OK.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|