CalcEmu.pm revision 7c478bd95313f5f23a4c958a745db2134aa03244
use 5.005;
use strict;
# use warnings; # dont use warnings for older Perls
use vars qw/$VERSION/;
$VERSION = '0.04';
# See SYNOPSIS below.
my $CALC_EMU;
BEGIN
{
}
sub __emu_band
{
{
# two's complement: inc and flip all "bits" in $bx
$bx =~ s/-?0x//;
}
else
{
$bx =~ s/-?0x//;
}
{
# two's complement: inc and flip all "bits" in $by
$by =~ s/-?0x//;
}
else
{
$by =~ s/-?0x//;
}
# now we have bit-strings from X and Y, reverse them for padding
# padd the shorter string
if ($diff > 0)
{
# if $yy eq "\x00", we can cut $bx, otherwise we need to padd $by
}
elsif ($diff < 0)
{
# if $xx eq "\x00", we can cut $by, otherwise we need to padd $bx
}
# and the strings together
# and reverse the result again
$bx = reverse $r;
# One of $x or $y was negative, so need to flip bits in the result.
# In both cases (one or two of them negative, or both positive) we need
# to get the characters back.
if ($sign == 1)
{
}
else
{
}
# leading zeros will be stripped by _from_hex()
# calculate sign of result
$x->{sign} = '+';
$x->round(@r);
}
sub __emu_bior
{
{
# two's complement: inc and flip all "bits" in $bx
$bx =~ s/-?0x//;
}
else
{
$bx =~ s/-?0x//;
}
{
# two's complement: inc and flip all "bits" in $by
$by =~ s/-?0x//;
}
else
{
$by =~ s/-?0x//;
}
# now we have bit-strings from X and Y, reverse them for padding
# padd the shorter string
if ($diff > 0)
{
}
elsif ($diff < 0)
{
}
# or the strings together
# and reverse the result again
$bx = reverse $r;
# one of $x or $y was negative, so need to flip bits in the result
# in both cases (one or two of them negative, or both positive) we need
# to get the characters back.
if ($sign == 1)
{
}
else
{
}
# leading zeros will be stripped by _from_hex()
# calculate sign of result
$x->{sign} = '+';
# if one of X or Y was negative, we need to decrement result
$x->round(@r);
}
sub __emu_bxor
{
{
# two's complement: inc and flip all "bits" in $bx
$bx =~ s/-?0x//;
}
else
{
$bx =~ s/-?0x//;
}
{
# two's complement: inc and flip all "bits" in $by
$by =~ s/-?0x//;
}
else
{
$by =~ s/-?0x//;
}
# now we have bit-strings from X and Y, reverse them for padding
# padd the shorter string
if ($diff > 0)
{
}
elsif ($diff < 0)
{
}
# xor the strings together
# and reverse the result again
$bx = reverse $r;
# one of $x or $y was negative, so need to flip bits in the result
# in both cases (one or two of them negative, or both positive) we need
# to get the characters back.
if ($sign == 1)
{
}
else
{
}
# leading zeros will be stripped by _from_hex()
# calculate sign of result
$x->{sign} = '+';
$x->round(@r);
}
##############################################################################
##############################################################################
1;
=head1 NAME
Math::BigInt::CalcEmu - Emulate low-level math with BigInt code
=head1 SYNOPSIS
Contains routines that emulate low-level math functions in BigInt, e.g.
optional routines the low-level math package does not provide on it's own.
Will be loaded on demand and automatically by BigInt.
Stuff here is really low-priority to optimize,
since it is far better to implement the operation in the low-level math
libary directly, possible even using a call to the native lib.
=head1 DESCRIPTION
=head1 METHODS
=head1 LICENSE
the same terms as Perl itself.
=head1 AUTHORS
(c) Tels http://bloodgate.com 2003, 2004 - based on BigInt code by
Tels from 2001-2003.
=head1 SEE ALSO
L<Math::BigInt>, L<Math::BigFloat>, L<Math::BigInt::BitVect>,
L<Math::BigInt::GMP> and L<Math::BigInt::Pari>.
=cut