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?

Honk

01-03-2004, 05:23 PM

Originally posted by coda:
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?

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

Omaha

01-03-2004, 08:21 PM

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

Honk

01-04-2004, 12:01 PM

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++.

Omaha

02-09-2005, 05:02 PM

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.

ScottManDeath

02-10-2005, 09:33 AM

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