473,396 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

What is the source of BUG/Warning

template <class X>
class Node{
:
:
};
template <class X>
class Link {
:
:
Node<X*a1, *a2;
};
int main( )
{
Link<floatlist1;
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?
Aug 7 '08 #1
2 1688
Pranav wrote:
template <class X>
class Node{
:
:
};
template <class X>
class Link {
:
:
Node<X*a1, *a2;
};
int main( )
{
Link<floatlist1;
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?
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 7 '08 #2
On Aug 7, 7:11 pm, Victor Bazarov <v.Abaza...@comAcast.netwrote:
Pranav wrote:
template <class X>
class Node{
:
:
};
template <class X>
class Link {
:
:
Node<X*a1, *a2;
};
int main( )
{
Link<floatlist1;
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?

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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Thank You Victor For Your Response..,
Aug 7 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Carl Owenby | last post by:
Re: Microsoft Knowledge Base Article - 174942 "File Modified Outside Source Editor" Warning Message I believe I have discovered a cause of this warning in a specific situation. I encountered...
26
by: Lasse Edsvik | last post by:
Hello I'm trying to build a simple COM+ app in vs.net using C# and i cant register it in component manager..... what more is needed than this: using System; using...
0
by: Carl Owenby | last post by:
Re: Microsoft Knowledge Base Article - 174942 "File Modified Outside Source Editor" Warning Message I believe I have discovered a cause of this warning in a specific situation. I encountered...
13
by: treble54 | last post by:
I need to build PHP from source with the pdo_ibm extension and I am having an issue with it. Firstly, I am using Visual Studio .NET 2003 and I am building PHP from source through the Visual Studio...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.