简体   繁体   English

无法打印右浮点值

[英]Unable to print right floating point value

I have my ZC706 board with dual arm cortex 32bit one. 我的ZC706主板带有32位双臂皮质。 I am trying to run an algorithm over it, as a part of the code it has floating point values. 我试图在其上运行一种算法,作为代码的一部分,它具有浮点值。

uint32_t int Ts = 69912;
float Ts_pico;
Ts_pico = 20*(10^-12)*Ts;
printf("Time stamp in picoseconds is %f", Ts_pico);

And it prints a value 4272595456.000000 instead of 1.39824*(10^-6) 它打印的值是4272595456.000000而不是1.39824 *(10 ^ -6)

So I tested by printing 所以我通过印刷测试

printf("The float point value is %f", 1.39824);

It was fine printing out the following value. 可以很好地打印以下值。

Next, when i tested by printing 接下来,当我通过打印测试时

double f = 10^-6;
printf("The flloat point value is %f", f);

The value it has printed is -14401872.000000 它打印的值是-14401872.000000

How can I solve the issue with floating point values? 如何解决浮点值的问题?

Didn't you want 10e-12 rather 10^-12 ? 您不是想要10e-12而是10^-12吗?

10e-12 is a floating point double constant , although do note that 1e-12 is 10 raised to the -12 th power. 10e-12是一个浮点 double 常量 ,尽管请注意1e-1210-12 次方 Your ^ is an abuse of the XOR operator. 您的^是XOR运算符的滥用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM