Написание калькулятора с разбором выражений, страница 5

        PUSH_Number (num_1);

        break;

      case 502:

        POP_Number (&num_1);

        num_1 = asin (num_1);

        PUSH_Number (num_1);

        break;

      case 501:

        POP_Number (&num_1);

        num_1 = cos (num_1);

        PUSH_Number (num_1);

        break;

      case 500:

        POP_Number (&num_1);

        num_1 = sin (num_1);

        PUSH_Number (num_1);

        break;

      case 400:

        POP_Number (&num_1);

        /*if (num_1 - (__int64)num_1 != 0 || num_1 < 0)

          printf ("ERROR #0xC002: %lf!\n", num_1);

        else  */

          num_1 = Factorial (num_1);

        PUSH_Number (num_1);

        break;

      case 300:

        POP_Number (&num_2);

        POP_Number (&num_1);

        if (num_1 == 0 && num_2 == 0)

          printf ("ERROR #C003: 0^0!\n");

        else

          num_1 = pow (num_1, num_2);

        PUSH_Number (num_1);

        break;

      case 100:

        POP_Number (&num_2);

        POP_Number (&num_1);

        num_1 += num_2;

        PUSH_Number (num_1);

        break;

      case 105:

        POP_Number (&num_2);

        POP_Number (&num_1);

        num_1 -= num_2;

        PUSH_Number (num_1);

        break;

      case 200:

        POP_Number (&num_2);

        POP_Number (&num_1);

        if (num_2 == 0)

          printf ("ERROR #0xC001: Division by zero!\n");

        else

          num_1 /= num_2;

        PUSH_Number (num_1);

        break;

      case 205:

        POP_Number (&num_2);

        POP_Number (&num_1);

        num_1 *= num_2;

        PUSH_Number (num_1);

        break;

      }

    }

    /* END OF 'CalcBuf' FUNCTION */

/********************************************************************

                END OF PRIVATE MEMBERS DEFINITIONS

********************************************************************/

/********************************************************************

                   PUBLIC MEMBERS DEFINITIONS

********************************************************************/

  public:

    /* DEFAULT CTOR DEFINITION */

    ICalc ()

    {

      IsCorrect = false;

      LastPriority = -0xFF;

      RisePriority = 0;

      FTC = (char*)malloc (0);

      FTC_Length = 0;

      FTC_Position = 0;

    }

    /* END OF DEFAULT CTOR DEFINITION */

    /* DTOR DEFINITION */

    ~ICalc ()

    {

      free (FTC);

    }

    /* END OF DTOR DEFINITION */

  public:

  /* DEFINITION OF AVAILABLE FUNCTIONS */

    /* THIS FUNCTION RESET THIS CLASS ELEMENTS */

    void Reset (void)

    {

      LastPriority = -0xFFFF;

      RisePriority = 0;

      FTC_Position = 0;

    }

    /* END OF 'Reset' FUNCTION */

    /* THIS FUNCTION RECEIVE CALCULATION FORMULA */

    void SetFTC (char *ptr)

    {

      FTC_Length = (int)strlen (ptr);

      FTC = (char*)malloc (FTC_Length);

      memmove (FTC, ptr, FTC_Length);

      DeleteSymbols ();

    }

    /* END OF 'SetFTC' FUNCTION */

    /* THIS METHOD IS NOT YET COMPLIETED

       NOT AVIALABLE TRIGONOMETRY METHODS

       SIN AND COS ARE AVIALABLE NOW */

    /* THIS FUNCTION IS CREATED FOR CALCULATION USERS FORMULA */