PI wird nicht richig ausgegeben

Gast #2988750
Lesenswert?

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

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren