You are here:

C++/Re:About a function that transforms a integar into string


I am sorry, I got the solution.

#include <math.h>
#include <stdio.h>

I didn't include the following header files which caused the error on the g++.

However, I have a different question.

I keep receiving a warning sign quoting " assignment to'int' from 'double'"

Can this warning could be of a great run time error threat?

Yes. But probably not in your case.


1.65432 as a double is converted to an int. What value do you get?

Answer: 1.

1.2334565E-23 as a double is converted to an int what value do you get?

Answer: 0.

If you did not realise that you had lost the precision and/or scale of the double by inadvertently converting to an int then yes it could be a very serious problem - particularly if this value is used to control something - drug compound mixes, rocket firing times or required thrust etc... or produce results on which predictions or the like are made - weather forecasts for example.

However in your case, if I remember correctly, you were using all integer values anyway so you only entered into the floating point domain to use pow anyway and the compiler only complains when you place the result back into an integer. The only things to watch out for are very large or small values - in which case using a floating point value might be preferable. Consider raising 2 to the 33rd power - this requires 33 bits and you only have 32 (assuming current common desktop computer types) of which only (approximately) 31 are of use for positive values for a signed 2s complement value. If your integers were unsigned 64 bit values then try raising 2 to the 65th power etc.. Obtaining overly large values from the likes of pow is easy, as is obtaining values less than 1 - try using 2 raised to the -1 for example (0.5 => 0 as an integer).  


All Answers

Answers by Expert:

Ask Experts


Ralph McArdell


I am a software developer with more than 15 years C++ experience and over 25 years experience developing a wide variety of applications for Windows NT/2000/XP, UNIX, Linux and other platforms. I can help with basic to advanced C++, C (although I do not write just-C much if at all these days so maybe ask in the C section about purely C matters), software development and many platform specific and system development problems.


My career started in the mid 1980s working as a batch process operator for the now defunct Inner London Education Authority, working on Prime mini computers. I then moved into the role of Programmer / Analyst, also on the Primes, then into technical support and finally into the micro computing section, using a variety of 16 and 8 bit machines. Following the demise of the ILEA I worked for a small company, now gone, called Hodos. I worked on a part task train simulator using C and the Intel DVI (Digital Video Interactive) - the hardware based predecessor to Indeo. Other projects included a CGI based train simulator (different goals to the first), and various other projects in C and Visual Basic (er, version 1 that is). When Hodos went into receivership I went freelance and finally managed to start working in C++. I initially had contracts working on train simulators (surprise) and multimedia - I worked on many of the Dorling Kindersley CD-ROM titles and wrote the screensaver games for the Wallace and Gromit Cracking Animator CD. My more recent contracts have been more traditionally IT based, working predominately in C++ on MS Windows NT, 2000. XP, Linux and UN*X. These projects have had wide ranging additional skill sets including system analysis and design, databases and SQL in various guises, C#, client server and remoting, cross porting applications between platforms and various client development processes. I have an interest in the development of the C++ core language and libraries and try to keep up with at least some of the papers on the ISO C++ Standard Committee site at


©2017 All rights reserved.

[an error occurred while processing this directive]