"Fossies" - the Fresh Open Source Software Archive

Member "install-tl-20200916/tlpkg/tlperl/lib/Math/BigFloat/Trace.pm" (7 Mar 2020, 1269 Bytes) of package /windows/misc/install-tl.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!perl
    2 
    3 package Math::BigFloat::Trace;
    4 
    5 require 5.010;
    6 use strict;
    7 use warnings;
    8 
    9 use Exporter;
   10 use Math::BigFloat;
   11 
   12 our ($accuracy, $precision, $round_mode, $div_scale);
   13 
   14 our @ISA = qw(Exporter Math::BigFloat);
   15 
   16 our $VERSION = '0.51';
   17 
   18 use overload;                   # inherit overload from Math::BigFloat
   19 
   20 # Globals
   21 $accuracy = $precision = undef;
   22 $round_mode = 'even';
   23 $div_scale = 40;
   24 
   25 sub new {
   26     my $proto = shift;
   27     my $class = ref($proto) || $proto;
   28 
   29     my $value = shift;
   30     my $a = $accuracy;
   31     $a = $_[0] if defined $_[0];
   32     my $p = $precision;
   33     $p = $_[1] if defined $_[1];
   34     my $self = Math::BigFloat->new($value, $a, $p, $round_mode);
   35 
   36     # remember, downgrading may return a BigInt, so don't meddle with class
   37     # bless $self, $class;
   38 
   39     print "MBF new '$value' => '$self' (", ref($self), ")";
   40     return $self;
   41 }
   42 
   43 sub import {
   44     print "MBF import ", join(' ', @_);
   45     my $self = shift;
   46 
   47     # we catch the constants, the rest goes go BigFloat
   48     my @a = ();
   49     foreach (@_) {
   50         push @a, $_ if $_ ne ':constant';
   51     }
   52     overload::constant float => sub { $self->new(shift); };
   53 
   54     Math::BigFloat->import(@a);                 # need it for subclasses
   55 #    $self->export_to_level(1,$self,@_);         # need this ?
   56 }
   57 
   58 1;