View Full Version : 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:
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, 07:21 PM
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++.
Omaha
02-09-2005, 04: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, 08:33 AM
No, technically, it is the definition of a literal float constant, casting would be (float)0.1 or float(0.1)
;)
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.