{"id":88,"date":"2015-10-19T20:27:01","date_gmt":"2015-10-19T18:27:01","guid":{"rendered":"http:\/\/www.legon.sk\/wp\/?p=88"},"modified":"2017-03-30T11:13:33","modified_gmt":"2017-03-30T09:13:33","slug":"udajove-typy","status":"publish","type":"post","link":"https:\/\/www.legon.sk\/wp\/?p=88","title":{"rendered":"\u00dadajov\u00e9 typy jazyka Pascal"},"content":{"rendered":"<h3><\/h3>\n<h3><strong>Celo\u010d\u00edseln\u00e9 typy<\/strong><\/h3>\n<h3><\/h3>\n<p>Pascal poskytuje p\u00e4\u0165 preddefinovan\u00fdch celo\u010d\u00edseln\u00fdch typov. Ka\u017ed\u00fd typ popisuje podmno\u017einu mno\u017einy cel\u00fdch \u010d\u00edsel. Ka\u017ed\u00fd typ m\u00e1 ur\u010dit\u00fd rozsah s\u00a0ktor\u00fdmi vie pracova\u0165 a\u00a0ak\u00e9 miesto zaber\u00e1 v\u00a0pam\u00e4ti, tabu\u013eke je uveden\u00fd ako ve\u013ekos\u0165.<\/p>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"118\"><strong>Typ<\/strong><\/td>\n<td width=\"336\">\n<h2>Rozsah hodn\u00f4t<\/h2>\n<\/td>\n<td width=\"84\"><strong>Ve\u013ekos\u0165<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"118\"><em>ShortInt<\/em><\/td>\n<td width=\"336\">-128 .. 127<\/td>\n<td width=\"84\">1 Byte<\/td>\n<\/tr>\n<tr>\n<td width=\"118\"><em>Integer<\/em><\/td>\n<td width=\"336\">-32 768 .. 32 767<\/td>\n<td width=\"84\">2 Byte<\/td>\n<\/tr>\n<tr>\n<td width=\"118\"><em>LongInt<\/em><\/td>\n<td width=\"336\">-2 147 483 648 .. 2 147 483 647<\/td>\n<td width=\"84\">4 Byte<\/td>\n<\/tr>\n<tr>\n<td width=\"118\"><em>Byte<\/em><\/td>\n<td width=\"336\">0 .. 255<\/td>\n<td width=\"84\">1 Byte<\/td>\n<\/tr>\n<tr>\n<td width=\"118\"><em>Word<\/em><\/td>\n<td width=\"336\">0 .. 65535<\/td>\n<td width=\"84\">2 Byte<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><em>S\u00a0celo\u010d\u00edseln\u00fdmi \u00fadajov\u00fdmi typmi m\u00f4\u017eeme vykon\u00e1va\u0165 oper\u00e1cie:<\/em><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>s\u010d\u00edtanie (+)<\/li>\n<li>od\u010d\u00edtanie (\u2013)<\/li>\n<li>\u00a0n\u00e1sobenie (*)<\/li>\n<li>\u00a0celo\u010d\u00edseln\u00fd podiel (div)<\/li>\n<li>\u00a0celo\u010d\u00edseln\u00fd zvy\u0161ok (mod)<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><em>Automatick\u00e9 \u010dinnosti s\u00a0cel\u00fdmi \u010d\u00edslami (funkcie a proced\u00fary)<\/em><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li><em>abs(x)<\/em> \u2013 absol\u00fatna hodnota x<\/li>\n<li><em>succ(x)<\/em> \u2013 nasledovn\u00edk x (\u010d\u00edslo o\u00a01 v\u00e4\u010d\u0161ie)<\/li>\n<li><em>pred(x)<\/em> \u2013 predchodca x (\u010d\u00edslo o\u00a0jedna ni\u017e\u0161ie)<\/li>\n<li><em>inc(x)<\/em> \u2013 zv\u00fd\u0161enie premennej x o\u00a01 (x:=x+1)<\/li>\n<li><em>dec(x)<\/em> \u2013 zn\u00ed\u017eenie premennej x o\u00a01 (x:=x-1)<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h1><strong>Re\u00e1lne \u010d\u00edsla<\/strong><\/h1>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"125\"><strong>Typ<\/strong><\/td>\n<td width=\"336\"><strong>rozsah<\/strong><\/td>\n<td width=\"84\"><strong>ve\u013ekos\u0165<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"125\"><em>real<\/em><\/td>\n<td width=\"336\">2,9*10<sup>-39<\/sup> .. 1,7*10<sup>+38<\/sup><\/td>\n<td width=\"84\">6 Byte<\/td>\n<\/tr>\n<tr>\n<td width=\"125\"><em>single<\/em><\/td>\n<td width=\"336\">1,5*10<sup>-45<\/sup> .. 3,4*10<sup>+38<\/sup><\/td>\n<td width=\"84\">4 Byte<\/td>\n<\/tr>\n<tr>\n<td width=\"125\"><em>double<\/em><\/td>\n<td width=\"336\">5,0*10<sup>-324<\/sup> .. 1,7*10<sup>+308<\/sup><\/td>\n<td width=\"84\">8 Byte<\/td>\n<\/tr>\n<tr>\n<td width=\"125\"><em>extendet<\/em><\/td>\n<td width=\"336\">3,4*10<sup>-4932<\/sup> .. 1,1*10<sup>+4932<\/sup><\/td>\n<td width=\"84\">10 Byte<\/td>\n<\/tr>\n<tr>\n<td width=\"125\"><em>comp<\/em><\/td>\n<td width=\"336\">-2<sup>-63<\/sup>+1 .. 2<sup>+63<\/sup>-1<\/td>\n<td width=\"84\">8 Byte<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><em>Oper\u00e1cie:<\/em><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>s\u010d\u00edtanie (+)<\/li>\n<li>od\u010d\u00edtanie (\u2013)<\/li>\n<li>n\u00e1sobenie (*)<\/li>\n<li>\u00a0delenie (\/)<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><em>Automatick\u00e9 \u010dinnosti s\u00a0cel\u00fdmi \u010d\u00edslami (funkcie a proced\u00fary)<\/em><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u00a0<em>sqrt (x)<\/em> &#8211; druh\u00e1 odmocnina x<\/li>\n<li><em>\u00a0sqr (x)<\/em> &#8211; druh\u00e1 mocnina x<\/li>\n<li>\u00a0<em>sin (x)<\/em> &#8211; sinus x<\/li>\n<li>\u00a0<em>cos (x)<\/em> &#8211; cosinus x<\/li>\n<li>\u00a0<em>arctan (x<\/em>) \u2013 arcustangens x<\/li>\n<li><em>\u00a0ln (x)<\/em> \u2013 prirodzen\u00fd logaritmus<\/li>\n<li><em>\u00a0exp(x) <\/em>&#8211; e<sup>x<\/sup><\/li>\n<li><em>\u00a0abs(x)<\/em> \u2013 absol\u00fatna hodnota x<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h1><strong>\u00dadajov\u00fd typ ZNAK (char)<\/strong><\/h1>\n<p>&nbsp;<\/p>\n<p>Znaky ako premenn\u00e9 v\u00a0pascale m\u00f4\u017eeme definova\u0165 pomocou typu <strong>char. <\/strong>Vyjadruj\u00fa sa ohrani\u010den\u00e9 apostrofmi pr. \u2018A\u2019 Inou mo\u017enos\u0165ou je zada\u0165 ich \u010d\u00edseln\u00fa hodnotu ktor\u00e1 sa nach\u00e1dza v ASCII tabu\u013eke. Pred t\u00fato \u010d\u00edseln\u00fa hodnotu sa mus\u00ed da\u0165 znak #.<\/p>\n<p>Na z\u00edskanie takejto \u010d\u00edselnej reprezent\u00e1cie znaku n\u00e1m sl\u00fa\u017eia funkcie:<\/p>\n<p>ord(\u2018A\u2019) = 65<\/p>\n<p>chr(65) = A<\/p>\n<p>Zmena mal\u00fdch p\u00edsmen na ve\u013ek\u00e9:<\/p>\n<p>Upcase<\/p>\n<p>&nbsp;<\/p>\n<h1>Logick\u00fd typ (boolean)<\/h1>\n<p>&nbsp;<\/p>\n<p>Ide o\u00a0\u00fadajov\u00fd typ Boolean, ktor\u00fd m\u00f4\u017ee nadob\u00fada\u0165 len 2 hodnoty:<\/p>\n<p>true \u2013 pravda<\/p>\n<p>false \u2013 nepravda<\/p>\n<p>&nbsp;<\/p>\n<p>Priorita oper\u00e1torov:<\/p>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"113\"><strong>Priorita<\/strong><\/td>\n<td width=\"228\"><strong>Oper\u00e1tor<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"113\">4<\/td>\n<td width=\"228\">not<\/td>\n<\/tr>\n<tr>\n<td width=\"113\">3<\/td>\n<td width=\"228\">*, \/, div, mod, and<\/td>\n<\/tr>\n<tr>\n<td width=\"113\">2<\/td>\n<td width=\"228\">+, -, or<\/td>\n<\/tr>\n<tr>\n<td width=\"113\">1<\/td>\n<td width=\"228\">=, &lt;&gt;, &gt;, &lt;, &lt;=, &gt;=<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>Oper\u00e1cie and, or, not:<\/p>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"41\"><strong>X<\/strong><\/td>\n<td width=\"48\"><strong>Y<\/strong><\/td>\n<td width=\"138\"><strong>X and Y<\/strong><\/td>\n<td width=\"182\"><strong>X or Y<\/strong><\/td>\n<td width=\"182\"><strong>not (X)<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"41\">false<\/td>\n<td width=\"48\">false<\/td>\n<td width=\"138\">false<\/td>\n<td width=\"182\">false<\/td>\n<td width=\"182\">true<\/td>\n<\/tr>\n<tr>\n<td width=\"41\">false<\/td>\n<td width=\"48\">true<\/td>\n<td width=\"138\">false<\/td>\n<td width=\"182\">true<\/td>\n<td width=\"182\">true<\/td>\n<\/tr>\n<tr>\n<td width=\"41\">true<\/td>\n<td width=\"48\">false<\/td>\n<td width=\"138\">false<\/td>\n<td width=\"182\">true<\/td>\n<td width=\"182\">false<\/td>\n<\/tr>\n<tr>\n<td width=\"41\">true<\/td>\n<td width=\"48\">true<\/td>\n<td width=\"138\">true<\/td>\n<td width=\"182\">true<\/td>\n<td width=\"182\">false<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><strong><br \/>\n<\/strong><\/p>\n<h5><\/h5>\n<h1>Typ Re\u0165azec (string)<\/h1>\n<p><strong>\u00a0<\/strong><\/p>\n<p>Jedn\u00e1 sa o\u00a0\u00fadajov\u00fd typ <strong>string,<\/strong> ktor\u00fd m\u00f4\u017ee ma\u0165 maxim\u00e1lne d\u013a\u017eku 255 znakov to znamen\u00e1 \u017ee sa jedn\u00e1 o\u00a0postupnos\u0165 znakov. Typ re\u0165azec je deklarovan\u00fd\u00a0 ak nieje deklarovan\u00e1 jeho ve\u013ekos\u0165 m\u00e1 preddeklarovan\u00fa ve\u013ekos\u0165 255 znakov. Re\u0165azcov\u00e9 kon\u0161tanty s\u00fa zapisovan\u00e9 v apostrofoch.<\/p>\n<p>&nbsp;<\/p>\n<p>Proced\u00fary a funkcie STRING<\/p>\n<p><strong><span style=\"color: #800000;\">Proced\u00fary<\/span><\/strong><\/p>\n<p><strong><span style=\"color: #0000ff;\">Funkcie<\/span><\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"383\"><span style=\"color: #800000;\"><strong>Delete<\/strong><\/span> (re\u0165azec, index1, po\u010det vymazan\u00fdch znakov);<\/td>\n<td width=\"231\">s:= \u2018jano\u2019\u00a0 delete(s, 2, 2)s=\u2019jo\u2019<\/td>\n<\/tr>\n<tr>\n<td width=\"383\"><span style=\"color: #800000;\"><strong>Insert<\/strong><\/span> (vklad. ret., ciel ret, poz\u00edcia 1 znaku vkladan\u00e9ho re\u0165azca)<\/td>\n<td width=\"231\">s:=\u2018kola\u2018\u00a0 Insert (\u2018by\u2019,s,3) s=\u2018kobyla\u2018<\/td>\n<\/tr>\n<tr>\n<td width=\"383\"><span style=\"color: #0000ff;\"><strong>Copy<\/strong><\/span> ([re\u0165azec, z\u00a0ktor\u00e9ho berieme],[index za\u010diatku], [po\u010det prvkov]);<\/td>\n<td width=\"231\">s:=copy(\u2018zna\u010dka\u2019, 3, 4)\u00a0 s=\u2018a\u010dka\u2018<\/td>\n<\/tr>\n<tr>\n<td width=\"383\"><span style=\"color: #0000ff;\"><strong>Concat<\/strong><\/span> zl\u00fa\u010di (s\u010d\u00edta) lubov. po\u010det re\u0165azcov<\/td>\n<td width=\"231\">s:= concat(\u2018ABC\u2019, \u2018CE\u2019, \u2018FGH\u2019) s=\u2018ABCCEFGH\u2018s:= \u2018abc\u2019+\u2019bcd\u2019+\u2019def\u2019 s=\u2019abcbcddef\u2019<\/td>\n<\/tr>\n<tr>\n<td width=\"383\"><span style=\"color: #800000;\"><strong>Val<\/strong><\/span> ([re\u0165azec], [premenn\u00e1 do ktorej sa ulo\u017e\u00ed \u010d\u00edslo], [chybov\u00fd k\u00f3d])<\/td>\n<td width=\"231\">Val(\u2018123\u2019, i, code)i, code: integercode=0 v\u0161etko OK ak \u010d\u00edslo je to \u010d\u00edslo kde do\u0161lo k\u00a0chybe<\/td>\n<\/tr>\n<tr>\n<td width=\"383\"><span style=\"color: #0000ff;\"><strong>Length<\/strong><\/span> \u2013 ur\u010d\u00ed d\u013a\u017eku re\u0165azca<\/td>\n<td width=\"231\">dlzka:= length(\u2018abc\u2019)dlzka = 3<\/td>\n<\/tr>\n<tr>\n<td width=\"383\"><strong><span style=\"color: #0000ff;\">pos<\/span> \u2013<\/strong> ur\u010d\u00ed poz\u00edciu podre\u0165azca v re\u0165azci<\/td>\n<td width=\"231\">s:=\u2019ahoj pascal\u2019;n:=pos(\u2018 \u2018,s);v n bude hodnota 5<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\" width=\"614\">\n<table>\n<tbody>\n<tr>\n<td width=\"383\"><strong><span style=\"color: #800000;\">str<\/span> \u2013<\/strong> premeni integer na string<\/td>\n<td width=\"231\">s:string ; str(123,s);<\/p>\n<p>s=&#8217;123&#8242;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Namiesto \u2018abc\u2019 m\u00f4\u017ee by\u0165 premenn\u00e1 typu string meno, priezvisko: string;\u00a0 concat (meno, priezvisko)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Celo\u010d\u00edseln\u00e9 typy Pascal poskytuje p\u00e4\u0165 preddefinovan\u00fdch celo\u010d\u00edseln\u00fdch typov. Ka\u017ed\u00fd typ popisuje podmno\u017einu mno\u017einy cel\u00fdch \u010d\u00edsel. Ka\u017ed\u00fd typ m\u00e1 ur\u010dit\u00fd rozsah s\u00a0ktor\u00fdmi vie pracova\u0165 a\u00a0ak\u00e9 miesto zaber\u00e1 v\u00a0pam\u00e4ti, tabu\u013eke je uveden\u00fd ako ve\u013ekos\u0165. &nbsp; Typ Rozsah hodn\u00f4t Ve\u013ekos\u0165 ShortInt -128 .. 127 1 Byte Integer -32 768 .. 32 767 2 Byte LongInt -2 147 483 &hellip; <a href=\"https:\/\/www.legon.sk\/wp\/?p=88\" class=\"more-link\">Pokra\u010dova\u0165 v \u010d\u00edtan\u00ed: <span class=\"screen-reader-text\">\u00dadajov\u00e9 typy jazyka Pascal<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[7],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-pascal","tag-pascal"],"_links":{"self":[{"href":"https:\/\/www.legon.sk\/wp\/index.php?rest_route=\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.legon.sk\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.legon.sk\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.legon.sk\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.legon.sk\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=88"}],"version-history":[{"count":6,"href":"https:\/\/www.legon.sk\/wp\/index.php?rest_route=\/wp\/v2\/posts\/88\/revisions"}],"predecessor-version":[{"id":177,"href":"https:\/\/www.legon.sk\/wp\/index.php?rest_route=\/wp\/v2\/posts\/88\/revisions\/177"}],"wp:attachment":[{"href":"https:\/\/www.legon.sk\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.legon.sk\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.legon.sk\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}