World Conquest Chronicles

World Conquest Chronicles

Robot Calculator, v1.1.0

The electronic calculator.

Support for NaN and infinity values, display the text block aligned vertically by the LCD center, update the dependencies, and perform refactoring.

Change Log

  • evaluation:
    • number evaluation:
      • support for special values:
        • support for NaN — NAN as a constant;
        • support for an infinity — INF as a constant;
    • refine the evaluation restrictions;
  • components:
    • displaying is made through the character LCD:
      • LCD dimensions are configurable;
  • displaying:
    • display the text block of two lines aligned vertically by the center;
    • display an input expression in the first line of the text block, aligned horizontally by the right side;
    • display a result of expression evaluation in the second line of the text block, aligned horizontally by the right side;
  • update the dependencies:
  • perform refactoring.

Features

  • evaluation:
    • number evaluation:
      • support for a whole number;
      • support for a fractional number:
        • support for a fractional number without a whole part;
        • support for a fractional number without a fractional part;
      • support for special values:
        • support for NaN — NAN as a constant;
        • support for an infinity — INF as a constant;
      • ignore duplicated zeros at the beginning of a number;
      • return NaN:
        • return NaN for an incorrect number;
        • return NaN for a number causing overflow;
      • truncate a number longer than the internal buffer;
    • operation evaluation:
      • supported operations:
        • addition;
        • subtraction;
        • multiplication;
        • division;
      • typo processing:
        • support for several operations in a row:
          • only operations with equal or growing priorities;
          • only the first operation will be used;
        • support for expression starting with an operation:
          • only operations with equal or growing priorities;
          • the leading operation will be ignored;
        • support for expression ending with an operation:
          • only operations with equal priorities;
          • the trailing operation will be ignored;
  • components:
    • displaying is made through the character LCD:
      • LCD dimensions are configurable;
    • controls:
      • expression input and evaluation is made through a 4x4 matrix membrane keypad;
      • clearing whole input is made through a separate button;
      • erasing one character is made through a separate button;
  • displaying:
    • display the text block of two lines aligned vertically by the center;
    • display an input expression in the first line of the text block, aligned horizontally by the right side;
    • display a result of expression evaluation in the second line of the text block, aligned horizontally by the right side.

Grammar

Grammar in an EBNF:

expression = addition;

addition = multiplication, {("+" | "-"), multiplication};
multiplication = number, {("*" | "/"), number};
number = NUMBER LITERAL | NUMBER CONSTANT;

NUMBER LITERAL = ? /(\d+\.\d*)|(\d*\.\d+)|\d+/ ?;
NUMBER CONSTANT = "NAN" | "INF";

Example of an expression: 1.2+2.3*4.2.