I have a series of if else if statements inside an overloaded << function that is to control how negative values are displayed with fractions. They all see to work except for one. If there is a fraction such as -2/-3 it should display as 2/3. So I am multiplying the numerator and the denominator by -1 to convert the sign but it is not working. I have used this strategy to move a negative denominator into a positive numerator so 2/-3 is -2/3 and that worked, so I can't see why it is not working with a double negative.
if you are already doing a routine that reduces the fractions somewhere (?) then I would put it in there. so if you had -4/-8 just fix it to 1/2 all in one place.
to do that you can just double down ;)
double d = num/den;
den = abs(den); //no matter what.
if (d>0) num = abs(num);
else num = abs(num)*-1;
Thanks to all you guys for the insight. I got it working. I ended up using my simplify function to handle negatives and the overloaded << function to display whole numbers, positive/negative mixed numbers, and any other fractions from the simplify function.