Mam do rozwiazana dwa dziwne problemy w php i nie mam pojecia jak je ugrysc. W php jest kalkulator binarny a ja nie moge go uzysc.
1) 8 do potegi 10000

2) Dodawanie swoch 1000 cyfrowych liczb

Bede wdzieczny za pomoc w dowolnym wypadku

Any ideas ?
<?php //$str1 = '12345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
91234567891234567891234567891'; //$str2 = '12345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
912345678912345678912345678912345678912345678912345678912345678912345678912345678
91234567891234567891234567891'; $str1 = '99999'; $str2 = '88888'; // ilośc iteracji w pętli $intLoopCount = ( $int1Count > $int2Count ) ? $int1Count : $int2Count; for( $i = ( $intLoopCount - 1 ), $j = 0; $i >= 0 ; $i--, $j++ ) { $intSum = $int1 + $int2; $arrResult[ $j ] = $arrResult[ $j ] + ( $intSum % 10 ); if( $intSum >= 10 ) { } } if( $arrResult[ 0 ] == 0 ) { } //print_r( $arrResult ); ?>
<pre> <?php class BigNumberAdder { public function add( $num_X, $num_Y ) { $length = $num_X->getLength(); $sum = BigNumber::createZero( $length + 1 ); // bo moze wystapic przeniesienie z ost pozycji: 9999 + 9999 --> 19998 $carry = 0; $partialSum = 0; // cyfry Xa i Yka $x = 0; $y = 0; $s = 0; // cyfra sumy // od ostatniej cyfry (najmniej znaczacej -- od jednosci) for ( $i = $length - 1; $i >= 0; $i-- ) { $x = $num_X->getDigit( $i ); $y = $num_Y->getDigit( $i ); $partialSum = $x + $y + $carry; $carry = (int)( $partialSum / 10 ); $s = $partialSum % 10; $sum->setdigit( $i + 1, $s ); } $sum->setDigit( 0, $carry ); return $sum; } } class BigNumber { private $length = 0; private function __construct() { } // tylko N pierwszych cyft jest akceptowanych // '1245' --> array( 1,2,4,5) { $number = new BigNumber(); for ( $i = 0; $i < $number->length; $i++ ) { } return $number; } { $number = new BigNumber(); $number->length = $length; return $number; } public function __toString() { } public function getLength() { return $this->length; } public function getDigit( $i ) { return $this->digits[ $i ]; } public function setDigit( $i, $digit ) { $this->digits[ $i ] = $digit; } } $num_1 = BigNumber::createFromString( '1245' ); $num_2 = BigNumber::createFromString( '9768' ); //$num_2 = BigNumber::createZero( 4 ); $adder = new BigNumberAdder(); $sum = $adder->add( $num_1, $num_2 ); ?></pre>