Lines Matching refs:scale

2202     my (@params, $scale);
2211 $scale = $params[0]+4; # at least four more for proper round
2217 $scale = abs($params[0] || $params[1]) + 4; # take whatever is defined
2227 $scale = $lx if $lx > $scale;
2228 $scale = $ly if $ly > $scale;
2230 $scale += $diff if $diff > 0; # if lx << ly, but not if ly << lx!
2262 # calculate the result to $scale digits and then round it
2264 $x->{_m} = $LIB->_lsft($x->{_m}, $LIB->_new($scale), 10);
2270 # correct for 10**scale
2272 = $LIB -> _ssub($x->{_e}, $x->{_es}, $LIB->_new($scale), '+');
2635 my ($scale, @params);
2643 $scale = $params[0]+4; # at least four more for proper round
2649 $scale = abs($params[0] || $params[1]) + 4; # take whatever is defined
2697 $x = $x -> _log_10($scale);
2700 my $base_log_e = $base -> copy() -> _log_10($scale);
2701 $x = $x -> bdiv($base_log_e, $scale);
2748 my ($scale, @params);
2763 $scale = $params[0];
2767 $scale = $params[0];
2776 #$scale = 1 + int(log($ms) / log(10) + $es) - $params[1];
2778 $scale = 1 + int($ndig) - $params[1];
2785 $scale += 4;
2832 # term to be added is smaller than "1E$scale", we can stop - f.i.
2833 # scale == 5, and we have 1/40320, then we stop since 1/40320 < 1E-5.
2864 if ($scale <= 75) {
2883 my $steps = _len_to_steps($scale - 4);
2884 # print STDERR "# Doing $steps steps for ", $scale-4, " digits\n";
2900 # compute A/B with $scale digits in the result (truncate, not round)
2901 $A = $LIB->_lsft($A, $LIB->_new($scale), 10);
2907 $x->{_e} = $LIB->_new($scale);
2992 my $rescale = int($scale + abs($expo) * log(2) / log(10) + 1);
3115 my ($scale, @params);
3128 $scale = $params[0];
3132 $scale = $params[0];
3137 $scale = 1 - $params[1];
3141 # Add more digits to the scale if the magnitude of $x is large.
3144 $scale += $e if $x >= 10;
3145 $scale = 4 if $scale < 4;
3175 # Compute constants to the current scale.
3177 my $pi = $class -> bpi($scale); # 𝜋
3190 $x = $x -> bmod($twopi, $scale);
3207 my $tol = $class -> new("1E-". ($scale-1));
3209 my $xsq = $x -> copy() -> bmul($x, $scale) -> bneg();
3222 $term -> bmul($xsq, $scale) -> bdiv($fac, $scale);
3224 $sin -> badd($term, $scale);
3245 # approximation, double the scale (accuracy) and retry.
3248 $scale *= 2;
3296 my ($scale, @params);
3309 $scale = $params[0]+4; # at least four more for proper round
3315 $scale = abs($params[0] || $params[1]) + 4; # take whatever is defined
3350 my $limit = $class->new("1E-". ($scale-1));
3356 my $next = $over->copy()->bdiv($below, $scale);
3417 my ($scale, @params);
3446 $scale = $params[0]+4; # at least four more for proper round
3452 $scale = abs($params[0] || $params[1]) + 4; # take whatever is defined
3458 my $pi = $class->bpi($scale - 3);
3473 $pi = $class->bpi($scale - 3);
3479 $x = $x->bdiv($x_copy, $scale);
3483 foreach (0 .. int($scale / 20)) {
3485 $x = $x->bdiv($x->copy()->bmul($x)->binc()->bsqrt($scale + 4)->binc(),
3486 $scale + 4);
3521 my $limit = $class->new("1E-". ($scale-1));
3527 my $next = $over->copy()->bdiv($below, $scale);
3597 my ($scale, @params);
3608 $scale = $params[0] + 4; # at least four more for proper round
3614 $scale = abs($params[0] || $params[1]) + 4; # take whatever is defined
3619 $y = $y -> bpi($scale) -> bmul("0.25"); # pi/4
3621 $y = $y -> bpi($scale) -> bmul("-0.25"); # -pi/4
3627 $y = $y -> bpi($scale) -> bmul("0.75"); # 3/4 pi
3629 $y = $y -> bpi($scale) -> bmul("-0.75"); # -3/4 pi
3631 $y = $y -> bpi($scale); # pi
3633 $y = $y -> bpi($scale) -> bneg(); # -pi
3637 $y = $y -> bpi($scale) -> bmul("0.5"); # pi/2
3639 $y = $y -> bpi($scale) -> bmul("-0.5"); # -pi/2
3641 $y = $y -> bdiv($x, $scale) -> batan($scale); # atan(y/x)
3644 my $pi = $class -> bpi($scale);
3646 $y = $y -> bdiv($x, $scale) -> batan() # atan(y/x) + pi
3649 $y = $y -> bdiv($x, $scale) -> batan() # atan(y/x) - pi
3654 $y = $y -> bpi($scale) -> bmul("0.5"); # pi/2
3656 $y = $y -> bpi($scale) -> bmul("-0.5"); # -pi/2
3693 my (@params, $scale);
3703 $scale = $params[0]+4; # at least four more for proper round
3709 $scale = abs($params[0] || $params[1]) + 4; # take whatever is defined
3713 # which is 2*$scale with possibly one extra digit to ensure that the
3717 my $n = 2 * $scale - $l; # how much should we shift?
3785 my (@params, $scale);
3794 $scale = $params[0]+4; # at least four more for proper round
3800 $scale = abs($params[0] || $params[1]) + 4; # take whatever is defined
3841 $x = $x->bsqrt($scale+4);
3844 my $u = $class->bone()->bdiv($x, $scale);
3871 my $u = $class->bone()->bdiv($y, $scale+4);
3874 $x = $x->bpow($u, $scale+4); # el cheapo
4300 my ($scale, $mode) = $x->_scale_a(@a);
4301 if (!defined $scale) { # no-op
4312 if (defined $x->{accuracy} && $x->{accuracy} < $scale) {
4318 # scale < 0 makes no sense
4319 # scale == 0 => keep all digits
4322 if ($scale <= 0 || $x->{sign} !~ /^[+-]$/) {
4330 if ($x->is_zero() || $LIB->_len($x->{_m}) <= $scale) {
4331 $x->{accuracy} = $scale if !defined $x->{accuracy} || $x->{accuracy} > $scale;
4340 $m = $m->bround($scale, $mode); # round mantissa
4342 $x->{accuracy} = $scale; # remember rounding
4358 my ($scale, $mode) = $x->_scale_p(@p);
4359 if (!defined $scale) {
4368 $x->{precision} = $scale if !defined $x->{precision} || $x->{precision} < $scale; # -3 < -2
4381 if (defined $x->{precision} && $x->{precision} < 0 && $scale < $x->{precision}) {
4387 $x->{precision} = $scale; # remember round in any case
4389 if ($scale < 0) {
4398 $scale = -$scale; # positive for simplicity
4407 # print "scale $scale dad $dad zad $zad len $len\n";
4417 if ($scale > $dad) { # 0.123, scale >= 3 => exit
4424 # 0.0065, scale -2, round last '0' with following '65' (scale == zad
4426 if ($scale < $zad) {
4432 if ($scale == $zad) { # for 0.006, scale -3 and trunc
4433 $scale = -$len;
4437 $scale = $scale-$zad;
4441 $scale = $dbd+$scale;
4447 # 123 => 100 means length(123) = 3 - $scale (2) => 1
4453 $scale = 1 if $scale == 0;
4455 if ($scale == 1 && $dbt <= $dbd) {
4463 if ($scale > $dbd) {
4467 } elsif ($scale == $dbd) {
4469 $scale = -$dbt;
4471 $scale = $dbd - $scale;
4477 $m = $m->bround($scale, $mode);
5549 # Remove implicit leading bit, scale up the mantissa
5812 my ($x, $scale) = @_;
5835 # scale used in intermediate computations
5836 my $scaleup = $scale + 4;
5877 $x = $x -> bround($scale);
5883 my ($x, $scale) = @_;
5937 if ($scale <= $LOG_10_A) {
5950 if ($scale <= $LOG_2_A) {
5967 if ($scale <= $LOG_10_A) {
5977 my $l_10; # value of ln(10) to A of $scale
5978 my $l_2; # value of ln(2) to A of $scale
5994 if ($scale <= $LOG_10_A) {
6006 if ($scale <= $LOG_2_A) {
6012 $l_2 = $l_2->_log($scale); # scale+4, actually
6015 $LOG_2_A = $scale;
6020 $l_10 = $l_10->_log($scale); # scale+4, actually
6028 $LOG_10_A = $scale;
6055 $x = $x->bdiv($two, $scale+4); # keep all digits
6057 $x = $x->bround($scale+4);
6062 if ($scale <= $LOG_2_A) {
6068 $l_2 = $l_2->_log($scale); # scale+4, actually
6071 $LOG_2_A = $scale;
6078 $x = $x->_log($scale); # need to do the "normal" way
6111 my ($scale, @params);
6121 $scale = $params[0]+4; # at least four more for proper round
6127 $scale = abs($params[0] || $params[1]) + 4; # take whatever is defined
6155 $u = $x->copy()->blog(undef, $scale)->bmul($y);
6165 $limit = $class->new("1E-". ($scale-1));
6170 $next = $over->copy()->bdiv($below, $scale);
6183 $x = $x->bone->bdiv($x_copy, $scale);
6806 supplied to the operation after the I<scale>:
6842 =item bfround ( +$scale )
6844 Rounds to the $scale'th place left from the '.', counting from the dot.
6847 =item bfround ( -$scale )
6849 Rounds to the $scale'th place right from the '.', counting from the dot.
6855 =item bround ( +$scale )
6857 Preserves accuracy to $scale digits from the left (aka significant digits) and
6861 =item bround ( -$scale ) and bround ( 0 )