I have a C function that returns a type float
.
When the function returns 1.0f
, the receiver sees 1065353216
, not 1.0
.
What I mean is, the following:
float Function()
{
return 1.0f;
}
float value;
value = Function();
fprintf(stderr, "Printing 1.0f: %f", value);
Displays:
1065353216
But not:
1.0
You define your function in one source file and call it from another one not providing the signature making the compiler think that the signature is int Function()
, which leads to strange results.
You should add the signature: float Function();
in the file where the printf
is.
For example:
float Function();
float value;
value = Function();
fprintf(stderr, "Printing 1.0f: %f", value);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With