Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,265 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,512 people online right now. Registration is fast and FREE... Join Now!




Warning: conversion from double to float

 
Reply to this topicStart new topic

Warning: conversion from double to float

hmapes
13 Dec, 2006 - 04:14 PM
Post #1

New D.I.C Head
*

Joined: 18 Sep, 2006
Posts: 13


My Contributions
Quick question - any ideas on how to fix a warning for conversion from double to float -possible loss of data error? only error i'm getting when program compiles.
User is offlineProfile CardPM
+Quote Post

eXceed69
RE: Warning: Conversion From Double To Float
13 Dec, 2006 - 04:29 PM
Post #2

"Super Sentai Knight Of DawN"
Group Icon

Joined: 12 Nov, 2006
Posts: 682



Thanked: 1 times
Dream Kudos: 675
My Contributions
For me that warnings can be avoided by changing the data type of the float to a double. If you more question try to post the your code for further evaluation of other member biggrin.gif


User is offlineProfile CardPM
+Quote Post

Xing
RE: Warning: Conversion From Double To Float
13 Dec, 2006 - 04:51 PM
Post #3

D.I.C Addict
Group Icon

Joined: 22 Jul, 2006
Posts: 723



Thanked: 2 times
Dream Kudos: 1575
My Contributions
Floating point constants are double by default. If you do something like this float num=3.4;
you will encounter this warning as 3.4 is double by default and you are trying to assign it to float which will cause data loss.

Solution:

1) Either change the type to double as said by eXceed69 or
2) Do this float num=3.4f;

This post has been edited by Xing: 13 Dec, 2006 - 04:52 PM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 07:27PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month