Sephy Posted April 23, 2008 Report Share Posted April 23, 2008 Tatad mana tabula bus sitaa te p q rezultats 0 0 0 0 1 1 1 0 1 1 1 0 p+q+p= q q+p+q= p vajadzigs skripts kas kaut cik automatizetu sito padarishanu piemers: 1000 0011 +1001 --------------- 0010 p.s. cerams ka piemers ir pareizi ;D Link to comment Share on other sites More sharing options...
Aleksejs Posted April 23, 2008 Report Share Posted April 23, 2008 Aizdomas, ka vajag xor operatoru: http://lv.php.net/manual/en/language.operators.bitwise.php $a = $b ^ $c ^ $d Link to comment Share on other sites More sharing options...
Sephy Posted April 23, 2008 Author Report Share Posted April 23, 2008 paldies tieshi tas ka vajadzigs Link to comment Share on other sites More sharing options...
Sephy Posted April 23, 2008 Author Report Share Posted April 23, 2008 (edited) nez nestradaa... <?php $binarais1=decbin(14); $binarais2=decbin(15); $rezultats=$binarais1^$binarais2; echo "<br>rezultata vertiba iznak $rezultats"; ?> ;[ Edited April 23, 2008 by Sephy Link to comment Share on other sites More sharing options...
Aleksejs Posted April 23, 2008 Report Share Posted April 23, 2008 decbin atgriež string. Tev nevajag pārveidot uz bināro - skaitlis ir un paliek tas pats skaitlis neatkarīgi no tā, kurā skaitīšanas sistēmā tas pierakstīts. Link to comment Share on other sites More sharing options...
Sephy Posted April 23, 2008 Author Report Share Posted April 23, 2008 Skaidrs tagad itkaa stradaa ;] Stulbi vienigi ka nevar normali apskatit rezultatu(jo piemeram salidzino 14 un 15 iznak 0001 bet paradas tikai 1 kad izvada ;P) Link to comment Share on other sites More sharing options...
Aleksejs Posted April 23, 2008 Report Share Posted April 23, 2008 a kāpēc 14, nevis 0000000000000000000014 ???? :D Link to comment Share on other sites More sharing options...
bubu Posted April 23, 2008 Report Share Posted April 23, 2008 Sephy: es jau tev te teicu: http://php.lv/f/index.php?s=&showtopic...ost&p=82590 Un nulles priekšā var dabūt tikai stringam. Integeram šīs nulles netiek ņemtas vērā, tāpēc tam tādas nevar pielikt. Link to comment Share on other sites More sharing options...
Sephy Posted April 23, 2008 Author Report Share Posted April 23, 2008 nujaa . a kapeec taa ir. KAPEEC tie nelieshi taa ir uztaisijushi php!?! ;D Link to comment Share on other sites More sharing options...
andrisp Posted April 23, 2008 Report Share Posted April 23, 2008 Sephy, "jebkurā" valodā tā ir. Un tas ir tikai normāli. Link to comment Share on other sites More sharing options...
Sephy Posted April 23, 2008 Author Report Share Posted April 23, 2008 skaidrs ;D Link to comment Share on other sites More sharing options...
bubu Posted April 23, 2008 Report Share Posted April 23, 2008 Tāpēc, ka skaitļa vērtība nemainās, ja tam pieraksta 0 priekšā patvaļīgā skaitā. Un kāda jēga glabāt kautkādas 0 (pie tam patvaļīgā skaitā tas var prasīt daudz vietas atmiņā), ja var neglabāt. T.i. 000123 = 123 = 000000000000000000000000000000000000000000000000123 utt. Nejauc skaitli ar stringu. Tās ir divas dažādas lietas. Link to comment Share on other sites More sharing options...
Recommended Posts