9 Years
Discussion Span
Last Post by daviddoria

Well, with how your code has plus 0.9999, you should leave total_gal_paint as a double. I assuming you want to chop off the decimals and round up if there are any decimals, hence the adding.

One way to get rid of the error is to leave total_gal_paint as a double but use setprecision(0) in front of the output so it would only show the integer part.

Another, if you want to store just the int is to have total_gal_paint be an int but write that line like this:

total_gal_paint = int( (total_area / coverage_gallon_paint) + (0.9999) );

That will convert it to an integer for you and should get rid of that error message.


This is called casting. The c++ style way to cast is

total_gal_paint = static_cast<int> ( (total_area / coverage_gallon_paint) + (0.9999) );

The code DemonGal711 posted is exactly the same thing as far as I know, its just a little "c style" :)

Also, it would be much easier if you posted the code using CODE tags rather than posting jpgs.


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.