What is the source of BUG/Warning

P

Pranav

template <class X>
class Node{
:
:
};


template <class X>
class Link {
:
:
Node<X> *a1, *a2;
};


int main( )
{
Link<float> list1;
int ret=0, x;

list1.addnode(0.1234);
:
:
:
}

I am gettin followin Bug/Warning when I use <float>
warning C4305: 'argument' : truncation from 'const double' to 'float'
also my data gets truncated into float to int..,


But when I use double I get no bug/warning..,

What may be the possible source of the bug/warning?
 
P

Pranav

The literal 0.1234 has the type 'double'. Your list 'list1' expects the
value of type 'float' (most likely, you didn't actually show), so the
compiler needs to truncate the value to fit (apparently 'double' and
'float' on your machine have different representations). You can get
rid of the warning if you add the 'f' suffix to your literal:

list1.addnode(0.1234f);

V

Thank You Victor For Your Response..,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,170
Messages
2,570,927
Members
47,469
Latest member
benny001

Latest Threads

Top