Obj-C Calculator - Radians to Degrees

前端 未结 5 1942
孤街浪徒
孤街浪徒 2021-01-21 11:26

I\'ve been watching the Stanford CS193P lectures and I\'ve been working on the assignment calculator. I got through the first assignment fairly easily, and I\'m trying to do the

相关标签:
5条回答
  • 2021-01-21 11:57

    Did you try

    sin( operand ) / 180.0 * M_PI
    
    0 讨论(0)
  • 2021-01-21 12:01

    Did you perhaps mean operand = sin(operand * M_PI / 180);?

    0 讨论(0)
  • 2021-01-21 12:02

    Where did you define operand?

    Are you sure that operand is a CGFloat and not a memory address?

    How are you formatting your output? If you are using %e it will output in scientific notation...try doing %f

    0 讨论(0)
  • 2021-01-21 12:04
    operand = sin(operand * (M_PI/180));
    
    0 讨论(0)
  • 2021-01-21 12:10

    Try this - It works for me:

        if ([operation isEqual:@"sin"])
        {
            operand = (operand * M_PI/180); // first convert the operand from radians to degrees then perform the operation
            operand = sin(operand);
        }
    

    Hope this helps

    0 讨论(0)
提交回复
热议问题