/usr/share/perl5/LaTeXML/Common/Number.pm is in latexml 0.8.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | # /=====================================================================\ #
# | LaTeXML::Common::Number | #
# | Representation of numbers | #
# |=====================================================================| #
# | Part of LaTeXML: | #
# | Public domain software, produced as part of work done by the | #
# | United States Government & not subject to copyright in the US. | #
# |---------------------------------------------------------------------| #
# | Bruce Miller <bruce.miller@nist.gov> #_# | #
# | http://dlmf.nist.gov/LaTeXML/ (o o) | #
# \=========================================================ooo==U==ooo=/ #
package LaTeXML::Common::Number;
use LaTeXML::Global;
use strict;
use warnings;
use LaTeXML::Common::Object;
use LaTeXML::Core::Token;
use base qw(LaTeXML::Common::Object);
use base qw(Exporter);
our @EXPORT = (qw(&Number));
#======================================================================
# Exported constructor.
sub Number {
my ($number) = @_;
return LaTeXML::Common::Number->new($number); }
#======================================================================
sub new {
my ($class, $number) = @_;
return bless [$number || "0"], $class; }
sub valueOf {
my ($self) = @_;
return $$self[0]; }
sub toString {
my ($self) = @_;
return $$self[0]; }
sub ptValue {
my ($self) = @_;
my $h = $$self[0] / 655.36;
return int($h < 0 ? $h - 0.5 : $h + 0.5) / 100; }
sub pxValue {
my ($self) = @_;
my $h = $$self[0] / 65536 * ($STATE->lookupValue('DPI') || 100 / 72.27);
return int($h < 0 ? $h - 0.5 : $h + 0.5); }
sub unlist {
my ($self) = @_;
return $self; }
sub revert {
my ($self) = @_;
return ExplodeText($self->toString); }
sub smaller {
my ($self, $other) = @_;
return ($self->valueOf < $other->valueOf) ? $self : $other; }
sub larger {
my ($self, $other) = @_;
return ($self->valueOf > $other->valueOf) ? $self : $other; }
sub absolute {
my ($self, $other) = @_;
return (ref $self)->new(abs($self->valueOf)); }
sub sign {
my ($self) = @_;
return ($self->valueOf < 0) ? -1 : (($self->valueOf > 0) ? 1 : 0); }
sub negate {
my ($self) = @_;
return (ref $self)->new(-$self->valueOf); }
sub add {
my ($self, $other) = @_;
return (ref $self)->new($self->valueOf + $other->valueOf); }
sub subtract {
my ($self, $other) = @_;
return (ref $self)->new($self->valueOf - $other->valueOf); }
# arg 2 is a number
sub multiply {
my ($self, $other) = @_;
return (ref $self)->new(int($self->valueOf * (ref $other ? $other->valueOf : $other))); }
sub stringify {
my ($self) = @_;
return "Number[" . $$self[0] . "]"; }
#======================================================================
1;
__END__
=pod
=head1 NAME
C<LaTeXML::Common::Number> - representation of numbers;
extends L<LaTeXML::Common::Object>.
=head2 Exported functions
=over 4
=item C<< $number = Number($num); >>
Creates a Number object representing C<$num>.
=back
=head2 Methods
=over 4
=item C<< @tokens = $object->unlist; >>
Return a list of the tokens making up this C<$object>.
=item C<< $string = $object->toString; >>
Return a string representing C<$object>.
=item C<< $string = $object->ptValue; >>
Return a value representing C<$object> without the measurement unit (pt)
with limited decimal places.
=item C<< $string = $object->pxValue; >>
Return an integer value representing C<$object> in pixels.
Uses the state variable C<DPI> (dots per inch).
=item C<< $n = $object->valueOf; >>
Return the value in scaled points (ignoring shrink and stretch, if any).
=item C<< $n = $object->smaller($other); >>
Return C<$object> or C<$other>, whichever is smaller
=item C<< $n = $object->larger($other); >>
Return C<$object> or C<$other>, whichever is larger
=item C<< $n = $object->absolute; >>
Return an object representing the absolute value of the C<$object>.
=item C<< $n = $object->sign; >>
Return an integer: -1 for negatives, 0 for 0 and 1 for positives
=item C<< $n = $object->negate; >>
Return an object representing the negative of the C<$object>.
=item C<< $n = $object->add($other); >>
Return an object representing the sum of C<$object> and C<$other>
=item C<< $n = $object->subtract($other); >>
Return an object representing the difference between C<$object> and C<$other>
=item C<< $n = $object->multiply($n); >>
Return an object representing the product of C<$object> and C<$n> (a regular number).
=back
=head1 AUTHOR
Bruce Miller <bruce.miller@nist.gov>
=head1 COPYRIGHT
Public domain software, produced as part of work done by the
United States Government & not subject to copyright in the US.
=cut
|