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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top