Skip to content

Commit

Permalink
Merge pull request #23 from Alex-Jordan/convert-nondecimal-base
Browse files Browse the repository at this point in the history
automatically print base for Real answers
  • Loading branch information
pstaabp authored Feb 14, 2024
2 parents 1b4c7bb + ced1be1 commit 0ab122a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions macros/contexts/contextBaseN.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ =head1 DESCRIPTION
greater than or equal to 2. The numbers will be stored internally in decimal, though parsed
and shown in the chosen base.
In addition, basic integer arithemetic (+,-,*,/,^) are available for these numbers.
In addition, basic integer arithemetic (+,-,*,/,%,^) are available for these numbers.
Division is defined in an integer sense.
The original purpose for this is simple conversion and operations in another base, however
Expand Down Expand Up @@ -91,9 +91,11 @@ =head2 Sample PG problem
BEGIN_PGML
Convert [$a] to base-5:
[$a] = [__]{$a_5}[`_5`]
[$a] = [__]*{$a_5}
END_PGML
ENDDOCUMENT();
The star variant answer blank will print the base in subscript after the answer blank.
=cut

sub _contextBaseN_init {
Expand Down Expand Up @@ -320,6 +322,11 @@ sub TeX {
return '\text{' . $self->string . '}';
}

sub ans_array {
my $self = shift;
return $self->ans_rule(@_) . main::math_ev3('_{' . $self->context->{base} . '}');
}

# Define division as integer division.
sub div {
my ($self, $l, $r, $other) = Value::checkOpOrderWithPromote(@_);
Expand Down

0 comments on commit 0ab122a

Please sign in to comment.