This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

怎样将一个double浮点变量打印输出



当我使用UARTprintf()打印输出一个int型变量时,是OK的,但该函数不支持浮点变量。

请问该如何打印输出一个浮点变量呢?

  • float Xangle,temp;

    temp = Xangle;

    printf("\r\n");

    if(Xangle>=0){
     printf("radX:%d.%d",(int32_t)temp ,(int32_t)((temp -(int32_t)temp )*1000));

    }

    else{

    temp = 0-temp; 

    printf("radX:-%d.%d",(int32_t)temp ,(int32_t)((temp -(int32_t)temp )*1000));

    }

    这个只能智取了