aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-066/steven-wilson/perl/ch-1.pl7
1 files changed, 4 insertions, 3 deletions
diff --git a/challenge-066/steven-wilson/perl/ch-1.pl b/challenge-066/steven-wilson/perl/ch-1.pl
index 63f4a85242..c6610b3adc 100644
--- a/challenge-066/steven-wilson/perl/ch-1.pl
+++ b/challenge-066/steven-wilson/perl/ch-1.pl
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-#
-#
+# Author: Steven Wilson
+# Date: 27 June 2020
use strict;
use warnings;
@@ -8,7 +8,7 @@ use feature qw/ say /;
use Test::More tests => 3;
ok( divide( 5, 2 ) == 2 );
-ok( divide( -5, 2 ) == -2 );
+ok( divide( -5, 2 ) == -3 );
ok( divide( -5, -2 ) == 2 );
sub divide {
@@ -21,6 +21,7 @@ sub divide {
}
if ( ( ( $M < 0 ) && ( $N > 0 ) ) || ( ( $N < 0 ) && ( $M > 0 ) ) ) {
$q = -$q;
+ if ($a != 0) { --$q }; # if neg and has remainder, floor number
}
$q;
}