truncation errors

float DX=.00050;
const float DEVIATION = .00050

is there a reason why declaring these 2 errors

warning C4305: 'initializing' : truncation from 'double' to 'float'
warning C4305: 'initializing' : truncation from 'double' to 'const float'

any reason to fix these Without declaring them as DOUBLE
Put an f on the end of the numbers so the compiler interprets them as a float.
It is not errors. It is warnings. To prevent issuing these warnings you can explicitly specify float number literals

float DX=.50.0f;
const float DEVIATION = .50.0f;

Also it is a bad idea to put leading zeroes because for integer literals such numbers are considered as octal numbers. For example, after the definition

int x = 012;

x will have value equal to 10.

EDIT: I am sorry. I did not see the point.:)
Last edited on
Topic archived. No new replies allowed.