This is a high-precision calculator application developed based on the Qt framework, supporting basic arithmetic operations (addition, subtraction, multiplication, division), and providing configurable decimal places settings. The calculator uses a custom high-precision numeric class to achieve accurate calculations, avoiding precision error issues in floating-point calculations.
- Support for four arithmetic operations: addition (+), subtraction (-), multiplication (*), division (/)
- Support for decimal point input
- Support for negative number operations
- Support for continuous calculations
- High-precision calculation to avoid floating-point precision errors
- Intuitive graphical user interface
- Clear calculation process display
- Keyboard shortcut support
- Right-click menu operation
- Status bar information prompts
- Customizable decimal places for calculation results
- Support for reset and clear operations
- Provide operation guide dialog box
- Include software information dialog box
- C++
- Qt Framework (Qt Widgets)
- Custom data structure for high-precision calculation
calculator/
├── calculator.pro # Qt project configuration file
├── calculator.pro.user # User project configuration
├── main.cpp # Program entry file
├── mainwindow.cpp # Main window implementation
├── mainwindow.h # Main window header file
├── mainwindow.ui # Main window UI design
├── node.cpp # Linked list node implementation
├── node.h # Linked list node header file
├── number.cpp # High-precision numeric class implementation
├── number.h # High-precision numeric class header file
├── tempnum.cpp # Temporary data management implementation
├── tempnum.h # Temporary data management header file
├── dialog_setbit.cpp # Decimal places setting dialog implementation
├── dialog_setbit.h # Decimal places setting dialog header file
├── dialog_setbit.ui # Decimal places setting dialog UI design
├── dialog_help.cpp # About dialog implementation
├── dialog_help.h # About dialog header file
├── dialog_help.ui # About dialog UI design
├── dialog_tip.cpp # Help tip dialog implementation
├── dialog_tip.h # Help tip dialog header file
├── dialog_tip.ui # Help tip dialog UI design
└── res/ # Resource folder
├── ICON.jpg # Application icon
└── res.qrc # Resource configuration file
Main window class responsible for handling user interface interaction and calculation logic scheduling.
- Manage button click events and keyboard shortcuts
- Coordinate numeric input and calculation operations
- Display calculation process and results
- Manage dialog boxes and menu operations
High-precision numeric class that uses a doubly linked list to implement high-precision numeric storage and calculation.
- Support for arithmetic operation operator overloading
- Provide input/output functionality for high-precision numbers
- Automatically handle carry and decimal places
- Support for custom decimal places
Linked list node class that forms the basic data unit of the Number class.
- Store single digit
- Support node insertion and traversal
- Maintain references to previous and next nodes
Temporary data management class that saves intermediate data during calculation.
- Store input numeric string
- Track calculation mode and status
- Manage operands and operators
- Qt development environment (Qt 5.x or Qt 6.x recommended)
- C++ compiler (supporting C++17 standard)
- Open the project file
calculator.prowith Qt Creator - Build the project (Ctrl+B)
- Run the program (Ctrl+R)
- Basic Calculation: Click on the number buttons to input values, click on the operator buttons to select the operation type, and click on the equals button to get the result
- Decimal Places Setting: Select "Modify Calculation Precision" from the menu bar, and enter the desired number of decimal places in the pop-up dialog box
- Keyboard Shortcuts:
- Numeric keys 0-9: Input corresponding numbers
- Operator keys +, -, *, /: Select corresponding operations
- Enter key: Calculate results
- Backspace key: Delete the last input character
- Delete key: Clear current input or all data
- Help Functions: View operation guides and about information through the menu bar
This calculator uses a doubly linked list to implement high-precision calculations, with each node storing a single digit. This design avoids precision issues in floating-point calculations and is particularly suitable for financial or scientific calculation scenarios that require precise results.
The core steps of high-precision calculation:
- Convert the input numeric string to a linked list storage structure
- Implement four arithmetic operations according to mathematical operation rules
- Handle carry, borrow, and decimal point positions
- Format the output result according to the set number of decimal places
- In division operations, results will be rounded according to the set number of decimal places
- During continuous calculations, the result of the previous calculation will automatically become the first operand of the next calculation
- To input a negative number, directly press the minus key in an empty input state
- When the number of decimal places is set to 0, all calculation results will be rounded to integers
- Follow Qt's naming conventions and coding style
- Class names use camel case (capitalized first letter)
- Member functions and variables use camel case (lowercase first letter)
- Constants use all uppercase letters with underscores
- Add scientific calculation functions (trigonometric functions, logarithms, etc.)
- Implement history record function
- Add theme switching function
- Support complex number operations
- Add unit conversion function
- Initial version
- Implement basic four arithmetic operations
- Support high-precision calculation
- Provide decimal places setting function
- Include help and about dialog boxes
MIT License
Thank you to the Qt framework for providing powerful GUI development capabilities, and to all developers who have helped with this project.
