Skip to content

Commit

Permalink
Merge pull request #25 from medvecky/handle_division_by_zero
Browse files Browse the repository at this point in the history
Handle division by zero
  • Loading branch information
medvecky authored Apr 15, 2024
2 parents 8507568 + f437271 commit 623ab0a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
## Changed

- Optimized command handling functions
- Updated README.md
- Updated README.md

# [v2.1.0] 2024-04-15

## Added

- functions for the operations with the stack
- error handling
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ The calculator supports the following operations:
| fsqr | square root |
| ftan | tangent in radians |
| fsgn | gives autonomous of the algebraic sign the number (-1; 0; 1) |
| ss | print the content of the stack |
| sc | clear the stack |
| spop | pop the first value of the stack |

Additionally, it accommodates floating-point numbers up to nine digits in both decimal (e.g., 3.14) and scientific (e.g., 8.9e-5) notations.

Expand Down
6 changes: 6 additions & 0 deletions src/modules/math_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ void FP_mult( void )

void FP_div( void )
{
if ( arg1Fp[ 0 ] == 0 && arg1Fp[ 1 ] == 0 && arg1Fp[ 2 ] == 0 && arg1Fp[ 3 ] == 0 && arg1Fp[ 4 ] == 0 )
{
puts( "[FP]: Division by zero" );
return;
}

FP_arg1ToFac();
__asm__ ( "lda #<%v", arg2Fp );
__asm__ ( "ldy #>%v", arg2Fp );
Expand Down

0 comments on commit 623ab0a

Please sign in to comment.