Sephy Posted April 23, 2008 Report Share Posted April 23, 2008 Man piemeram ir tris mainigie: $pirmais=1;$otrais=2;$tresajs=3; Kaa var salikt visus tris vienaa citaa mainigajaaa: $ciparrinda=123; Link to comment Share on other sites More sharing options...
Vebers Posted April 23, 2008 Report Share Posted April 23, 2008 $rinda = $pirmais.$otrais.$tresais; Link to comment Share on other sites More sharing options...
Sephy Posted April 23, 2008 Author Report Share Posted April 23, 2008 paldies Link to comment Share on other sites More sharing options...
Sephy Posted April 23, 2008 Author Report Share Posted April 23, 2008 Velviens jautajums: Man vajag pielikt skaitlim liekas nulles. Tas ir teiksim man obligati vajag 4 ciparus manaa mainigajaa tapec jabut $pirmais=0001; $desmitais=0010; $simtajs=0100; $tukstoshais=1000; varbut var kautkaa noradit cik skaitliem jabut un php automatiski piemet taas nulles?! Link to comment Share on other sites More sharing options...
Dooling Posted April 23, 2008 Report Share Posted April 23, 2008 Apsakties funkciju str_pad(). Varbūt tas derēs Link to comment Share on other sites More sharing options...
Sephy Posted April 23, 2008 Author Report Share Posted April 23, 2008 oki paldies Link to comment Share on other sites More sharing options...
bubu Posted April 23, 2008 Report Share Posted April 23, 2008 Vispār jau to "salikšanu" kopā dara šādi: $ciparrinda = ($pirmais*10 + $otrais)*10 + $tresajs; Ar . operatoru tu dabūsi stringu nevis skaitli. 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 (edited) $ciparrinda = ($pirmais*10 + $otrais)*10 + $tresajs; hmm kapec tur reizina ar 10?! edit:pats sapratu... 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 Tāpēc, ka skaitlis 234512 = 2 + 10*1 + 10*10*5 + 10*10*10*4 + 10*10*10*10*3 + 10*10*10*10*10*2 =2+10*(1+10*(5+10*(4+10*(3+10*(2))))) 10 - tāpēc, ka decimālā sistēma! Link to comment Share on other sites More sharing options...
Sephy Posted April 23, 2008 Author Report Share Posted April 23, 2008 a kaa var saskaitit binaros skaitlus ;D. sitaa te $iznakums=decbin("10")+decbin("20"); ?!! vai kaa?! Link to comment Share on other sites More sharing options...
Aleksejs Posted April 23, 2008 Report Share Posted April 23, 2008 Nu... ja decimālajā sistēmā ir 10, tad binārajā... Kā Tev šķiet? :) Link to comment Share on other sites More sharing options...
Sephy Posted April 23, 2008 Author Report Share Posted April 23, 2008 tur ira 1 un 0 ;D Link to comment Share on other sites More sharing options...
Aleksejs Posted April 23, 2008 Report Share Posted April 23, 2008 decimālajai sistēmai - bāze ir 10 binārajai - 2 tātad - 1001110 = 0+2*(1+2*(1+2*(1+2*(0+2*(0+2*(1)))))) = 0*2^0 + 1*2^1 + 1*2^2 + 1*2^3 + 0*2^4 + 0*2^5 + 1*2^6 Link to comment Share on other sites More sharing options...
Sephy Posted April 23, 2008 Author Report Share Posted April 23, 2008 (edited) hmm laikam neprecizi izteicos ;D. Parastos es skaitlus gribeju 'salikt' kopaa ko arii izdariju, bet binaros es gribu pa istam saskaitit man vajag saskatit kopaa decbin('10') un decbin('20') un dabut summu nevis skaitla virkni! edit: piemeri $pirmais=1;$otrais=2;$tresajs=3; 1)salikt rezultataa izvedojass 123 2)sakaitit rezutataa sanaktu 1+2+3=6 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(10+20) Link to comment Share on other sites More sharing options...
Recommended Posts