jenny
jenny

Reputation: 520

Unable to print right floating point value

I have my ZC706 board with dual arm cortex 32bit one. 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)

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

How can I solve the issue with floating point values?

Upvotes: 1

Views: 83

Answers (1)

Bathsheba
Bathsheba

Reputation: 234855

Didn't you want 10e-12 rather 10^-12?

10e-12 is a floating point double constant, although do note that 1e-12 is 10 raised to the -12th power. Your ^ is an abuse of the XOR operator.

Upvotes: 5

Related Questions