# Lldb error?

#1

I’ve combed through this code over and over and even rewrote it from scratch twice and I keep getting an ‘(lldb)’ message in the output instead of the ‘(%.2f, %.2f) becomes (%.2f, %.2f radians)’ in the output. Any help?

[code]
#include <stdio.h>
#include <math.h>

void cartesianToPolar (double x, double y, double *rPtr, double *thetaPtr)
{
*rPtr = sqrt(x * x + y * y);

``````double theta;
if (x == 0.0) {
if (y == 0.0) {
theta = 0.0;
} else if (y > 0) {
theta = M_PI_2;
} else {
theta = - M_PI_2;
}
} else {
theta = atan(y/x);
}
*thetaPtr = theta;
``````

}

int main(int argc, const char * argv[])
{
double pi = 3.14;
double integerPart;
double fractionPart;

``````fractionPart = modf(pi, &integerPart);

printf("integerPart = %.0f, fractionPart = %.2f\n", integerPart, fractionPart);

double x = 3.0;
double y = 4.0;
double angle;

return 0;
``````

}[/code]

Thanks!

#2

So I finally got frustrated and pasted in the code from another post just to see the outcome in action - it worked, then I used undo to get back my broken code, ran it again and it worked.

I’m not sure what happened there but I would really like to know

my code:

[code]#include <stdio.h>
#include <math.h>

void cartesianToPolar (double x, double y, double *rPtr, double *thetaPtr)
{
*rPtr = sqrt(x * x + y * y);

``````double theta;
if (x == 0.0) {
if (y == 0.0) {
theta = 0.0;
} else if (y > 0) {
theta = M_PI_2;
} else {
theta = - M_PI_2;
}
} else {
theta = atan(y/x);
}
*thetaPtr = theta;
``````

}

int main(int argc, const char * argv[])
{
double pi = 3.14;
double integerPart;
double fractionPart;

``````fractionPart = modf(pi, &integerPart);

printf("integerPart = %.0f, fractionPart = %.2f\n", integerPart, fractionPart);

double x = 3.0;
double y = 4.0;
double angle;

return 0;
``````

}
[/code]

Forum code:

[code]#include <stdio.h>
#include <math.h>

void cartesianToPolar(double x, double y, double *rPtr, double *thetaPtr)
{
*rPtr = sqrt(x * x + y * y);

// Calculate theta
double theta;
if (x == 0.0) {
if (y == 0.0) {
theta = 0.0; // technically considered undefined.
} else if (y > 0) {
theta = M_PI_2;
} else {
theta = -M_PI_2;
}
} else {
theta = atan(y / x);
}
// Store theta in the supplied address
*thetaPtr = theta;
}

int main(int argc, const char * argv[])
{
double x = 3.0;
double y = 4.0;
double angle;

return 0;
}[/code]

#3

Thought I should post the workaround to my lldb error problem - but if all the code is solid but you keep getting lldb errors try this:

Cut all the code from your file (ctrl +x)

Save the blank file

Paste the code back in

save

If all the code is correct your lldb error should be gone. I do not know why it works, if someone could explain it that would be awesome

#4

That doesn’t look like an error; that looks more like a break point activation.

``````...
(lldb)
...
integerPart = 3, fractionPart = 0.14
(lldb)
...``````

If you see the b[/b] output in the console for no reason, it could be that you have accidentally put a break point on a statement and ran the program.

#5

Aha! If only I had know that 2+ months ago!

Thanks for enlightening me