Solver Subtraction of signed numbers
Algebra
->
Signed-numbers
-> Solver Subtraction of signed numbers
Log On
Algebra: Operations with Signed Numbers
Section
Solvers
Solvers
Lessons
Lessons
Answers archive
Answers
Source code of 'Subtraction of signed numbers'
This Solver (Subtraction of signed numbers)
was created by by
ichudov(507)
:
View Source
,
Show
,
Put on YOUR site
About ichudov
:
I am not a paid tutor, I am the owner of this web site!
==section input This is the <B>subtraction</B> solver. There is also a separate <A HREF=addition-of-signed-numbers.solver>addition</A> solver. Calculate and explain: *[input a=4] <FONT SIZE=+3 COLOR=red>-</FONT> *[input b=-2]. ==section solution perl $sum = $a-$b; if( $b < 0 ) { print "$b is a negative number. As you know, subtraction of a negative number is equivalent to ADDITION of its opposite (positive number). In our case, subtracting $b is equivalent to ADDING " . (-$b) . ". {{{$a- $b = $a+" . (-$b) . "}}} The sum of $a and " . (-$b) . " is $sum. That's your answer.\n\n\n"; } else { print "In this instance, since $b is a positive number, we simply need to perform the subtractionoperation. $a-$b = $sum."; } my $minx = -10; $minx = $a if $a < $minx; $minx = $b if $b < $minx; $minx = $sum if $sum < $minx; $minx--; my $maxx = 10; $maxx = $a if $a > $maxx; $maxx = $b if $b > $maxx; $maxx = $sum if $sum > $maxx; $maxx++; print "{{{ number_line( 400, $minx, $maxx, $a, $b, $sum ) }}}"; ==section output sum ==section check a=5 b=-3 sum=8