warnings with opengl float conversion

I get warnings of: conversion from double to float: possible loss of data when i use the command:

glVertex3f(0,y-(1.414*w),1.0f);
where w & y are float variables

how to remove the warnings?

Originally posted by coda:
[b]I get warnings of: conversion from double to float: possible loss of data when i use the command:

glVertex3f(0,y-(1.414*w),1.0f);
where w & y are float variables

how to remove the warnings?[/b]

glVertex3f(0,y-(1.414f*w),1.0f);

You can either disable that warning (compiler specific) or do a cast to insist that it’s what you want.

There is no need to cast or to disable a compiler warning.

As I stated in my previous post he only needs to add a ‘f’ after ‘1.414’

This is really one of the simplest things to know about C/C++.

Adding the f is the easiest way, the way I would do it, AND an implied cast. By default real values are interpreted as doubles, so adding the f will change the interpretation; which in the end is what we’re doing with casting, now isn’t it?

Wow, talk about digging an old post up.

No, technically, it is the definition of a literal float constant, casting would be (float)0.1 or float(0.1)

:wink: