Hallo, ich möchte mit Hilfe von meinem AVR board stelle für stelle PI ausgeben. das problem ist, das folgendes ausgegeben wird: 3.14159280000... Ich post mal den Code mit: # define F_CPU 16000000L #include <avr/io.h> #include <util/delay.h> #include <math.h> #include "AODEF.h" #include "usart.h" int stelle(int k); long double PI = 3.14159265; int main(void) { USART_Init(MYUBRR); int k = 0; int ziffer; while(1) { ziffer = stelle(k); k++; USART_Send_int(ziffer); _delay_ms(1000); } } int stelle(int k) { long double pi_doub; long double pi_int; pi_doub = pow(10,k)*PI; pi_int = (int)pi_doub; pi_doub = pi_doub-pi_int; pi_doub=pi_doub*10; pi_int=(int)pi_doub; return pi_int; } Hoffe jemand kann mir helfen, schon mal danke im vorraus
Sorry > long double PI = 3.14159265; auf dem AVR gibt es keinen long double. float, double, long double ist alles dasselbe: float, mit 4 Byte Speicherverbrauch. Mehr als 5 bis 6 signifikante Stellen darfst du dir nicht erwarten.
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.