I'm having issues with the simple inclusion/exclusion of a single
#include <iostream> statement
in a source file which is strictly dedicated to defining two
functions for calculating the column widths of a series of integers
and their squares. If the statement is excluded, the calculation of
the width of the integers column is incorrect; when it's included,
the calculation is correct.
There should be absolutely no reason to include the statement in this
file as all output statements are handled from the main function.
As you can guess, I'm not very experienced at this. I've had to get
a POS PC for some coursework that I'm taking, so tried to compile the
same project in Dev-C++. The above behavior is not exhibited in that
environment, so I'm mystified. If anyone's interested, here's the code:
#include "FindColWidths.h"
#include <cmath>
//#include <iostream> //........................Here is the line in
question...........................
using std::fabs;
using std::pow;
int findRootWidth(double i, double width) {
if (fabs(i) < pow(10, width)) {
return int(width) + 2;
}
else {
return findRootWidth(i, width + 1);
}
}
int findSqrWidth(double i, double width){
if (pow(i, 2) < pow(10, width)) {
return int(width) + 1;
}
else {
return findSqrWidth(i, width + 1);
}
}
Sample output logs: With #include <iostream> enabled:
Absolute Largest: 1001
RootWidth: 6
-10 100
-9 81
With #include <iostream> disabled:
Absolute Largest: 1001
RootWidth: 3
-10 100
-9 81
TIA
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden