[{"data":1,"prerenderedAt":277},["ShallowReactive",2],{"tag-labels":3,"site-header":4,"article-pascal-debugging-fpc-gdb-en":75},{},{"featuredPost":5,"navigations":29},{"id":6,"title":7,"title_id":8,"slug":9,"excerpt":10,"excerpt_id":11,"has_translation":12,"published_at":13,"reading_time":14,"hidden_from_listing":15,"tags":16,"thumbnail_image":21,"og_image":22,"series":23,"authors":28},110,"When You Pick a Framework Just to Look Different","Ketika Pilih Framework Cuma Biar Kelihatan Beda","ketika-pilih-framework-cuma-biar-kelihatan-beda","The last time you chose a new framework or library, was it because your problem needed that tool, or because it sounded cool and few people around you were using it? That question is uncomfortable. Technology decisions are often made for reasons that never appear in any technical document.","Terakhir kali kamu milih framework atau library baru, itu karena masalahmu butuh alat itu, atau karena alatnya kedengaran keren dan belum banyak yang pakai? Pertanyaan ini nggak enak dijawab. Soalnya keputusan teknologi sering diambil dengan alasan yang nggak pernah ditulis di dokumen teknis mana pun.",true,"2026-10-06T15:25:21.000Z",5,false,[17,18,19,20],"karier","framework","opini","pengalaman",null,"\u002Fog\u002Fketika-pilih-framework-cuma-biar-kelihatan-beda.png",{"id":24,"title":25,"title_id":26,"slug":27},9,"Articles","Artikel","all",[],[30,49,70],{"collection":31,"item":32},"series",{"__typename":31,"title":25,"title_id":26,"slug":27,"children_series":33},[34,38,42,46],{"title":35,"title_id":36,"slug":37},"Artificial Intelligence","Kecerdasan Artifisial","kecerdasan-artifisial",{"title":39,"title_id":40,"slug":41},"Programming Fundamentals","Konsep Dasar Pemrograman","konsep-dasar-pemrograman",{"title":43,"title_id":44,"slug":45},"Algorithms and Data Structures","Algoritma dan Struktur Data","algoritma-struktur-data",{"title":47,"title_id":47,"slug":48},"LLM Systems","llm-systems",{"collection":31,"item":50},{"__typename":31,"title":51,"title_id":51,"slug":52,"children_series":53},"Tutorial","tutorial",[54,58,62,66],{"title":55,"title_id":56,"slug":57},"Learning Python","Belajar Python","belajar-python",{"title":59,"title_id":60,"slug":61},"Learning Go","Belajar Golang","belajar-golang",{"title":63,"title_id":64,"slug":65},"Learning Java","Belajar Java","belajar-java",{"title":67,"title_id":68,"slug":69},"Learning Pascal","Belajar Pascal","belajar-pascal",{"collection":31,"item":71},{"__typename":31,"title":72,"title_id":72,"slug":73,"children_series":74},"Lab","lab",[],{"article":76,"renderedBody":167,"renderedTakeaway":168,"latestArticles":169,"toc":257},{"id":77,"title":78,"title_id":79,"slug":80,"excerpt":81,"excerpt_id":82,"has_translation":12,"published_at":83,"reading_time":84,"hidden_from_listing":15,"tags":85,"thumbnail_image":21,"og_image":88,"series":89,"authors":155,"seoTitle":21,"seoDescription":21,"body_locale":158,"available_locales":159,"body":161,"takeway":162,"prerequisite":163},161,"Debugging Free Pascal with -gl and gdb","Men-debug Free Pascal dengan -gl dan gdb","pascal-debugging-fpc-gdb","A run with no prices ends at a hex address and status 217. `-gl` names the line, gdb names the values, and the mean of six positive prices comes out negative because `integer` is 2 bytes.","Jalan tanpa satu harga pun berakhir di alamat hex dan status 217. `-gl` menyebut barisnya, gdb menyebut nilainya, dan rata-rata dari enam harga positif keluar negatif karena `integer` berukuran 2 byte.","2026-11-18T01:00:00.000Z",7,[86,87],"pascal","debugging","\u002Fog\u002Fpascal-debugging-fpc-gdb.png",{"id":90,"title":67,"title_id":68,"slug":69,"description":91,"description_id":92,"articles":93,"children_series":121,"parent_series":146},14,"Pascal is a humane language with a friendly syntax. It's easy to read and easy to write, which is why so many schools and universities still use it as a first language. Start here and take it one step at a time.","Pascal, bahasa pemrograman yang manusiawi dengan sintaksnya yang *friendly*. Dikenal karena kemudahan pemahaman dan implementasinya, Pascal banyak digunakan sebagai bahasa pemrograman dasar bagi para pelajar dan mahasiswa. Yuk mulai belajar Pascal bareng Inva!",[94,103],{"id":77,"title":78,"title_id":79,"slug":80,"excerpt":81,"excerpt_id":82,"has_translation":12,"published_at":83,"reading_time":84,"hidden_from_listing":15,"tags":85,"thumbnail_image":21,"og_image":88,"series":95,"authors":96},{"id":90,"title":67,"title_id":68,"slug":69},[97],{"authors_id":98},{"id":99,"name":100,"slug":101,"role":102,"profile_picture":21},1,"Daffa Izzuddin","izzudd","Writer",{"id":104,"title":105,"title_id":106,"slug":107,"excerpt":108,"excerpt_id":109,"has_translation":12,"published_at":110,"reading_time":111,"hidden_from_listing":15,"tags":112,"thumbnail_image":21,"og_image":116,"series":117,"authors":118},163,"Pascal Capstone: Why Every Gradebook Score Came Back Zero","Capstone Pascal: Kenapa Semua Skor Buku Nilai Kembali Nol","pascal-gradebook-capstone","A gradebook reads three students from a file, prints three rows, and every score is 0. The procedure filled a copy of the array, because the parameter was missing `var`. Add the word and the report matches the file; the compiler had already warned about the call that filled nothing.","Sebuah buku nilai membaca tiga siswa dari berkas, mencetak tiga baris, dan setiap skornya 0. Prosedurnya mengisi salinan array, karena parameternya kehilangan `var`. Tambahkan kata itu dan laporannya cocok dengan berkasnya; kompilator sudah memperingatkan soal pemanggilan yang tidak mengisi apa pun.","2026-11-20T01:00:00.000Z",6,[86,113,114,115],"record","array","prosedur","\u002Fog\u002Fpascal-gradebook-capstone.png",{"id":90,"title":67,"title_id":68,"slug":69},[119],{"authors_id":120},{"id":99,"name":100,"slug":101,"role":102,"profile_picture":21},[122,128,134,140],{"id":123,"title":124,"title_id":125,"slug":126,"description":127,"cover_image":21},23,"Getting Started with Pascal","Berkenalan dengan Bahasa Pascal","pascal-intro","Install Free Pascal on Windows or Linux, write Hello World, then learn how a Pascal program is put together, comments and arithmetic included.",{"id":129,"title":130,"title_id":131,"slug":132,"description":133,"cover_image":21},24,"Control Structures","Struktur Kontrol","pascal-struktur-kontrol","Boolean expressions, if-else and case-of branching, and the three kinds of loop Pascal gives you.",{"id":135,"title":136,"title_id":137,"slug":138,"description":139,"cover_image":21},25,"Composite Types","Tipe Data Bentukan","pascal-tipe-data-bentukan","Types you build yourself: record, array, and the pointer that keeps confusing everyone at first.",{"id":141,"title":142,"title_id":143,"slug":144,"description":145,"cover_image":21},26,"Procedural Programming","Pemrograman Prosedural","pascal-pemrograman-prosedural","Break a big program into small procedures and functions you can call again and again.",{"id":99,"title":51,"title_id":51,"slug":52,"parent_series":21,"children_series":147},[148,150,152,154],{"id":149,"title":55,"title_id":56,"slug":57,"cover_image":21},10,{"id":151,"title":59,"title_id":60,"slug":61,"cover_image":21},11,{"id":153,"title":63,"title_id":64,"slug":65,"cover_image":21},13,{"id":90,"title":67,"title_id":68,"slug":69,"cover_image":21},[156],{"authors_id":157},{"id":99,"name":100,"slug":101,"role":102,"profile_picture":21},"en",[158,160],"id","\nThe program below sums prices from the command line and prints their mean. Run it with no prices and it prints `count: 0`, then an unhandled exception at the hex address `$000000000040120A`, and exits with status 217. Nothing in that output names a line of your source. Here is the program.\n\n```pascal\nprogram average;\n\n{ Sums the prices given on the command line and prints the count and the mean. }\n\nuses SysUtils;\n\nvar\n  i, count: integer;\n  sum: integer;\n\nbegin\n  sum := 0;\n  count := ParamCount;\n  for i := 1 to count do\n    sum := sum + StrToInt(ParamStr(i));\n  writeln('count: ', count);\n  writeln('mean: ', sum div count);\nend.\n```\n\n## The address is not a line number\n\nCompile it the usual way and run it with no arguments. This is the default build.\n\n```plain\n$ fpc -vw average.pas && .\u002Faverage\ncount: 0\nmean: An unhandled exception occurred at $000000000040120A:\nEDivByZero: Division by zero\n  $000000000040120A\n```\n\nThe shell reports exit status 217. The message says something divided by zero, but the address after it is only a position inside the compiled binary. You cannot open it in your editor.\n\nOne flag fixes this. With `-gl`, FPC prints the line next to the address.\n\n```plain\n$ fpc -vw -gl average.pas && .\u002Faverage\ncount: 0\nmean: An unhandled exception occurred at $000000000040120A:\nEDivByZero: Division by zero\n  $000000000040120A  main,  line 17 of average.pas\n```\n\nNow the last line reads `main,  line 17 of average.pas`. Open the file and look at line 17. The only division there is `sum div count`, and `count` is 0 when you pass no prices.\n\n## Let gdb stop it where it breaks\n\nA line number tells you where the program died, not what the variables held. For that, run the program inside gdb, which halts it at the moment of failure.\n\nKeep the `-gl` build from the last step. The option `-ex run` starts the program, and `-ex bt` prints a backtrace once it stops.\n\n```text\n$ gdb --batch -ex run -ex bt .\u002Faverage\nProgram received signal SIGFPE, Arithmetic exception.\n0x000000000040120a in main () at average.pas:17\n17\t  writeln('mean: ', sum div count);\n#0  0x000000000040120a in main () at average.pas:17\n```\n\nRead it from the top. The first line names the signal, SIGFPE, which matches the `EDivByZero` message you saw before. The second gives the address, the routine `main`, and the place `average.pas:17`. The third prints the source line itself, so you do not even need to open the file.\n\nThe last line is the backtrace: the chain of routine calls that led to the stop, newest first. Here the chain has a single entry, `main`.\n\n## Stop it one line earlier and look inside\n\nNow give the program real prices and stop it before line 17 runs. The command `break 17` sets a breakpoint, a line where gdb pauses before executing it. The option `--args` hands the prices to your program. Each `print` shows the current value of an expression.\n\n```text\n$ gdb --batch -ex 'break 17' -ex run -ex 'print sum' -ex 'print count' -ex 'print sum div count' --args .\u002Faverage 12000 15000 9500 10500 8000 7500\nBreakpoint 1 at 0x4011d2: file average.pas, line 17.\n\nBreakpoint 1, main () at average.pas:17\n17\t  writeln('mean: ', sum div count);\n$1 = -3036\n$2 = 6\n$3 = -506\n```\n\ngdb stopped before the division ran, and it hands you the values. `count` is 6, which is right. `sum` is -3036, and `sum div count` would give -506. Six positive prices cannot add up to a negative number.\n\n## The sum that went negative\n\nRun the same prices without gdb to see what a user sees.\n\n```plain\n$ fpc -vw average.pas && .\u002Faverage 12000 15000 9500 10500 8000 7500\ncount: 6\nmean: -506\n```\n\nThe exit status is 0. The program does not crash, and it prints a wrong answer.\n\nThe cause is the type of `sum`. In FPC's default mode, `integer` takes 2 bytes. Ask the compiler with a second small program.\n\n```pascal\nprogram sizes;\nbegin\n  writeln('sizeof(integer) = ', sizeof(integer));\n  writeln('high(integer) = ', high(integer));\n  writeln('sizeof(longint) = ', sizeof(longint));\nend.\n```\n\n```plain\n$ fpc -vw sizes.pas && .\u002Fsizes\nsizeof(integer) = 2\nhigh(integer) = 32767\nsizeof(longint) = 4\n```\n\nThe largest `integer` is 32767. The prices are 12000, 15000, 9500, 10500, 8000 and 7500, and they add to 62500. That does not fit, so the variable wrapped around: 62500 minus 65536 leaves -3036. Dividing by 6 gives -506. Compile the same file with `-Mobjfpc` and `integer` becomes 4 bytes, with `sizeof(integer) = 4` and `high(integer) = 2147483647`.\n\nThe fix is to declare `sum: longint`. The mean then prints with `\u002F` instead of `div`, and `:0:1` gives one digit after the point. A test on `count` makes the no-price run say `mean: no data`. The full file is in the last section.\n\n## Make the silent version stop too\n\nThe wrong run exited with status 0, and nobody was told. You can ask FPC to stop on a value that does not fit. The option `-Cr` turns on range checking. Build the buggy program with it and keep `-gl` for the line.\n\n```plain\n$ fpc -vw -gl -Cr average.pas && .\u002Faverage 12000 15000 9500 10500 8000 7500\nAn unhandled exception occurred at $00000000004011A0:\nERangeError: Range check error\n  $00000000004011A0  main,  line 15 of average.pas\n```\n\nThe run now ends with status 217 and names line 15, which is `sum := sum + StrToInt(ParamStr(i));`. That is the line where the sum wraps. The option `-Co` alone did not catch it on this build: the run still printed `count: 6` and `mean: -506` with no error. Use `-Cr`.\n\n## A check you can run\n\nThis program reads the two lines `average` prints and compares them with the expected answer.\n\n```pascal\nprogram check_average;\n\n{ Reads the lines average prints and compares them with the expected answer. }\n\nconst\n  expected: array[1..2] of string = ('count: 6', 'mean: 10416.7');\n\nvar\n  line: string;\n  i, passed: integer;\n\nbegin\n  passed := 0;\n  i := 0;\n  while (not eof) and (i \u003C 2) do\n  begin\n    readln(line);\n    i := i + 1;\n    if line = expected[i] then\n    begin\n      passed := passed + 1;\n      writeln('PASS  line ', i, ': ', line);\n    end\n    else\n      writeln('FAIL  line ', i, ': expected ', expected[i], ', got ', line);\n  end;\n  writeln;\n  writeln(passed, ' of 2 checks passed');\n  if passed \u003C> 2 then\n    ExitCode := 1;\nend.\n```\n\nWith the buggy source still in place, compile both files and pipe the program's output into the checker.\n\n```plain\n$ fpc -vw average.pas && fpc -vw check_average.pas && .\u002Faverage 12000 15000 9500 10500 8000 7500 | .\u002Fcheck_average\nPASS  line 1: count: 6\nFAIL  line 2: expected mean: 10416.7, got mean: -506\n\n1 of 2 checks passed\n```\n\nThat is the red run. Line 2 fails, and `check_average` exits with status 1. Now replace `average.pas` with the fixed source.\n\n```pascal\nprogram average;\n\n{ Sums the prices given on the command line and prints the count and the mean. }\n\nuses SysUtils;\n\nvar\n  i, count: integer;\n  sum: longint;\n\nbegin\n  sum := 0;\n  count := ParamCount;\n  for i := 1 to count do\n    sum := sum + StrToInt(ParamStr(i));\n  writeln('count: ', count);\n  if count = 0 then\n    writeln('mean: no data')\n  else\n    writeln('mean: ', sum \u002F count:0:1);\nend.\n```\n\nRun the same command again.\n\n```plain\n$ fpc -vw average.pas && .\u002Faverage 12000 15000 9500 10500 8000 7500 | .\u002Fcheck_average\nPASS  line 1: count: 6\nPASS  line 2: mean: 10416.7\n\n2 of 2 checks passed\n```\n\nThat is the green run, with exit status 0. The run with no prices, the one that started all this, no longer crashes.\n\n```plain\n$ fpc -vw average.pas && .\u002Faverage\ncount: 0\nmean: no data\n```\n\nRebuild with `-gl` first when a program stops at a bare hex address, and set a breakpoint one line before the calculation when it exits 0 with the wrong number.\n","- An unhandled exception prints a hex address; `-gl` makes FPC add `main, line 17 of average.pas` to it.\n- gdb stops the program where it breaks and prints the variables, which a line number alone cannot tell you.\n- In FPC's default mode `integer` is 2 bytes, so six prices that add to 62500 leave the variable at -3036.\n- `sum: longint` and `\u002F` with `:0:1` fix both the wrapped sum and the truncated mean.\n- `-Cr` turns the silent wrap into a range check error that names the line; `-Co` alone did not catch it on this build.\n- A checker that reads the program's output turns a wrong number nobody noticed into a failing line.",{"id":164,"title":165,"slug":166},146,"Pascal Units: One Average, Two Answers","pascal-units","\u003Cp>The program below sums prices from the command line and prints their mean. Run it with no prices and it prints \u003Ccode>count: 0\u003C\u002Fcode>, then an unhandled exception at the hex address \u003Ccode>$000000000040120A\u003C\u002Fcode>, and exits with status 217. Nothing in that output names a line of your source. Here is the program.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PASCAL\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"program%20average%3B%0A%0A%7B%20Sums%20the%20prices%20given%20on%20the%20command%20line%20and%20prints%20the%20count%20and%20the%20mean.%20%7D%0A%0Auses%20SysUtils%3B%0A%0Avar%0A%20%20i%2C%20count%3A%20integer%3B%0A%20%20sum%3A%20integer%3B%0A%0Abegin%0A%20%20sum%20%3A%3D%200%3B%0A%20%20count%20%3A%3D%20ParamCount%3B%0A%20%20for%20i%20%3A%3D%201%20to%20count%20do%0A%20%20%20%20sum%20%3A%3D%20sum%20%2B%20StrToInt(ParamStr(i))%3B%0A%20%20writeln('count%3A%20'%2C%20count)%3B%0A%20%20writeln('mean%3A%20'%2C%20sum%20div%20count)%3B%0Aend.\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>program average;\n\n{ Sums the prices given on the command line and prints the count and the mean. }\n\nuses SysUtils;\n\nvar\n  i, count: integer;\n  sum: integer;\n\nbegin\n  sum := 0;\n  count := ParamCount;\n  for i := 1 to count do\n    sum := sum + StrToInt(ParamStr(i));\n  writeln('count: ', count);\n  writeln('mean: ', sum div count);\nend.\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Ch2 id=\"the-address-is-not-a-line-number\">The address is not a line number\u003C\u002Fh2>\n\u003Cp>Compile it the usual way and run it with no arguments. This is the default build.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20fpc%20-vw%20average.pas%20%26%26%20.%2Faverage%0Acount%3A%200%0Amean%3A%20An%20unhandled%20exception%20occurred%20at%20%24000000000040120A%3A%0AEDivByZero%3A%20Division%20by%20zero%0A%20%20%24000000000040120A\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ fpc -vw average.pas &amp;&amp; .\u002Faverage\u003C\u002Fspan>\ncount: 0\nmean: An unhandled exception occurred at $000000000040120A:\nEDivByZero: Division by zero\n  $000000000040120A\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The shell reports exit status 217. The message says something divided by zero, but the address after it is only a position inside the compiled binary. You cannot open it in your editor.\u003C\u002Fp>\n\u003Cp>One flag fixes this. With \u003Ccode>-gl\u003C\u002Fcode>, FPC prints the line next to the address.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20fpc%20-vw%20-gl%20average.pas%20%26%26%20.%2Faverage%0Acount%3A%200%0Amean%3A%20An%20unhandled%20exception%20occurred%20at%20%24000000000040120A%3A%0AEDivByZero%3A%20Division%20by%20zero%0A%20%20%24000000000040120A%20%20main%2C%20%20line%2017%20of%20average.pas\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ fpc -vw -gl average.pas &amp;&amp; .\u002Faverage\u003C\u002Fspan>\ncount: 0\nmean: An unhandled exception occurred at $000000000040120A:\nEDivByZero: Division by zero\n  $000000000040120A  main,  line 17 of average.pas\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Now the last line reads \u003Ccode>main,  line 17 of average.pas\u003C\u002Fcode>. Open the file and look at line 17. The only division there is \u003Ccode>sum div count\u003C\u002Fcode>, and \u003Ccode>count\u003C\u002Fcode> is 0 when you pass no prices.\u003C\u002Fp>\n\u003Ch2 id=\"let-gdb-stop-it-where-it-breaks\">Let gdb stop it where it breaks\u003C\u002Fh2>\n\u003Cp>A line number tells you where the program died, not what the variables held. For that, run the program inside gdb, which halts it at the moment of failure.\u003C\u002Fp>\n\u003Cp>Keep the \u003Ccode>-gl\u003C\u002Fcode> build from the last step. The option \u003Ccode>-ex run\u003C\u002Fcode> starts the program, and \u003Ccode>-ex bt\u003C\u002Fcode> prints a backtrace once it stops.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">TEXT\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20gdb%20--batch%20-ex%20run%20-ex%20bt%20.%2Faverage%0AProgram%20received%20signal%20SIGFPE%2C%20Arithmetic%20exception.%0A0x000000000040120a%20in%20main%20()%20at%20average.pas%3A17%0A17%09%20%20writeln('mean%3A%20'%2C%20sum%20div%20count)%3B%0A%230%20%200x000000000040120a%20in%20main%20()%20at%20average.pas%3A17\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>$ gdb --batch -ex run -ex bt .\u002Faverage\nProgram received signal SIGFPE, Arithmetic exception.\n0x000000000040120a in main () at average.pas:17\n17\t  writeln('mean: ', sum div count);\n#0  0x000000000040120a in main () at average.pas:17\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Read it from the top. The first line names the signal, SIGFPE, which matches the \u003Ccode>EDivByZero\u003C\u002Fcode> message you saw before. The second gives the address, the routine \u003Ccode>main\u003C\u002Fcode>, and the place \u003Ccode>average.pas:17\u003C\u002Fcode>. The third prints the source line itself, so you do not even need to open the file.\u003C\u002Fp>\n\u003Cp>The last line is the backtrace: the chain of routine calls that led to the stop, newest first. Here the chain has a single entry, \u003Ccode>main\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Ch2 id=\"stop-it-one-line-earlier-and-look-inside\">Stop it one line earlier and look inside\u003C\u002Fh2>\n\u003Cp>Now give the program real prices and stop it before line 17 runs. The command \u003Ccode>break 17\u003C\u002Fcode> sets a breakpoint, a line where gdb pauses before executing it. The option \u003Ccode>--args\u003C\u002Fcode> hands the prices to your program. Each \u003Ccode>print\u003C\u002Fcode> shows the current value of an expression.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">TEXT\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20gdb%20--batch%20-ex%20'break%2017'%20-ex%20run%20-ex%20'print%20sum'%20-ex%20'print%20count'%20-ex%20'print%20sum%20div%20count'%20--args%20.%2Faverage%2012000%2015000%209500%2010500%208000%207500%0ABreakpoint%201%20at%200x4011d2%3A%20file%20average.pas%2C%20line%2017.%0A%0ABreakpoint%201%2C%20main%20()%20at%20average.pas%3A17%0A17%09%20%20writeln('mean%3A%20'%2C%20sum%20div%20count)%3B%0A%241%20%3D%20-3036%0A%242%20%3D%206%0A%243%20%3D%20-506\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>$ gdb --batch -ex 'break 17' -ex run -ex 'print sum' -ex 'print count' -ex 'print sum div count' --args .\u002Faverage 12000 15000 9500 10500 8000 7500\nBreakpoint 1 at 0x4011d2: file average.pas, line 17.\n\nBreakpoint 1, main () at average.pas:17\n17\t  writeln('mean: ', sum div count);\n$1 = -3036\n$2 = 6\n$3 = -506\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>gdb stopped before the division ran, and it hands you the values. \u003Ccode>count\u003C\u002Fcode> is 6, which is right. \u003Ccode>sum\u003C\u002Fcode> is -3036, and \u003Ccode>sum div count\u003C\u002Fcode> would give -506. Six positive prices cannot add up to a negative number.\u003C\u002Fp>\n\u003Ch2 id=\"the-sum-that-went-negative\">The sum that went negative\u003C\u002Fh2>\n\u003Cp>Run the same prices without gdb to see what a user sees.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20fpc%20-vw%20average.pas%20%26%26%20.%2Faverage%2012000%2015000%209500%2010500%208000%207500%0Acount%3A%206%0Amean%3A%20-506\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ fpc -vw average.pas &amp;&amp; .\u002Faverage 12000 15000 9500 10500 8000 7500\u003C\u002Fspan>\ncount: 6\nmean: -506\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The exit status is 0. The program does not crash, and it prints a wrong answer.\u003C\u002Fp>\n\u003Cp>The cause is the type of \u003Ccode>sum\u003C\u002Fcode>. In FPC&#39;s default mode, \u003Ccode>integer\u003C\u002Fcode> takes 2 bytes. Ask the compiler with a second small program.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PASCAL\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"program%20sizes%3B%0Abegin%0A%20%20writeln('sizeof(integer)%20%3D%20'%2C%20sizeof(integer))%3B%0A%20%20writeln('high(integer)%20%3D%20'%2C%20high(integer))%3B%0A%20%20writeln('sizeof(longint)%20%3D%20'%2C%20sizeof(longint))%3B%0Aend.\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>program sizes;\nbegin\n  writeln('sizeof(integer) = ', sizeof(integer));\n  writeln('high(integer) = ', high(integer));\n  writeln('sizeof(longint) = ', sizeof(longint));\nend.\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20fpc%20-vw%20sizes.pas%20%26%26%20.%2Fsizes%0Asizeof(integer)%20%3D%202%0Ahigh(integer)%20%3D%2032767%0Asizeof(longint)%20%3D%204\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ fpc -vw sizes.pas &amp;&amp; .\u002Fsizes\u003C\u002Fspan>\nsizeof(integer) = 2\nhigh(integer) = 32767\nsizeof(longint) = 4\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The largest \u003Ccode>integer\u003C\u002Fcode> is 32767. The prices are 12000, 15000, 9500, 10500, 8000 and 7500, and they add to 62500. That does not fit, so the variable wrapped around: 62500 minus 65536 leaves -3036. Dividing by 6 gives -506. Compile the same file with \u003Ccode>-Mobjfpc\u003C\u002Fcode> and \u003Ccode>integer\u003C\u002Fcode> becomes 4 bytes, with \u003Ccode>sizeof(integer) = 4\u003C\u002Fcode> and \u003Ccode>high(integer) = 2147483647\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Cp>The fix is to declare \u003Ccode>sum: longint\u003C\u002Fcode>. The mean then prints with \u003Ccode>\u002F\u003C\u002Fcode> instead of \u003Ccode>div\u003C\u002Fcode>, and \u003Ccode>:0:1\u003C\u002Fcode> gives one digit after the point. A test on \u003Ccode>count\u003C\u002Fcode> makes the no-price run say \u003Ccode>mean: no data\u003C\u002Fcode>. The full file is in the last section.\u003C\u002Fp>\n\u003Ch2 id=\"make-the-silent-version-stop-too\">Make the silent version stop too\u003C\u002Fh2>\n\u003Cp>The wrong run exited with status 0, and nobody was told. You can ask FPC to stop on a value that does not fit. The option \u003Ccode>-Cr\u003C\u002Fcode> turns on range checking. Build the buggy program with it and keep \u003Ccode>-gl\u003C\u002Fcode> for the line.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20fpc%20-vw%20-gl%20-Cr%20average.pas%20%26%26%20.%2Faverage%2012000%2015000%209500%2010500%208000%207500%0AAn%20unhandled%20exception%20occurred%20at%20%2400000000004011A0%3A%0AERangeError%3A%20Range%20check%20error%0A%20%20%2400000000004011A0%20%20main%2C%20%20line%2015%20of%20average.pas\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ fpc -vw -gl -Cr average.pas &amp;&amp; .\u002Faverage 12000 15000 9500 10500 8000 7500\u003C\u002Fspan>\nAn unhandled exception occurred at $00000000004011A0:\nERangeError: Range check error\n  $00000000004011A0  main,  line 15 of average.pas\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The run now ends with status 217 and names line 15, which is \u003Ccode>sum := sum + StrToInt(ParamStr(i));\u003C\u002Fcode>. That is the line where the sum wraps. The option \u003Ccode>-Co\u003C\u002Fcode> alone did not catch it on this build: the run still printed \u003Ccode>count: 6\u003C\u002Fcode> and \u003Ccode>mean: -506\u003C\u002Fcode> with no error. Use \u003Ccode>-Cr\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Ch2 id=\"a-check-you-can-run\">A check you can run\u003C\u002Fh2>\n\u003Cp>This program reads the two lines \u003Ccode>average\u003C\u002Fcode> prints and compares them with the expected answer.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PASCAL\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"program%20check_average%3B%0A%0A%7B%20Reads%20the%20lines%20average%20prints%20and%20compares%20them%20with%20the%20expected%20answer.%20%7D%0A%0Aconst%0A%20%20expected%3A%20array%5B1..2%5D%20of%20string%20%3D%20('count%3A%206'%2C%20'mean%3A%2010416.7')%3B%0A%0Avar%0A%20%20line%3A%20string%3B%0A%20%20i%2C%20passed%3A%20integer%3B%0A%0Abegin%0A%20%20passed%20%3A%3D%200%3B%0A%20%20i%20%3A%3D%200%3B%0A%20%20while%20(not%20eof)%20and%20(i%20%3C%202)%20do%0A%20%20begin%0A%20%20%20%20readln(line)%3B%0A%20%20%20%20i%20%3A%3D%20i%20%2B%201%3B%0A%20%20%20%20if%20line%20%3D%20expected%5Bi%5D%20then%0A%20%20%20%20begin%0A%20%20%20%20%20%20passed%20%3A%3D%20passed%20%2B%201%3B%0A%20%20%20%20%20%20writeln('PASS%20%20line%20'%2C%20i%2C%20'%3A%20'%2C%20line)%3B%0A%20%20%20%20end%0A%20%20%20%20else%0A%20%20%20%20%20%20writeln('FAIL%20%20line%20'%2C%20i%2C%20'%3A%20expected%20'%2C%20expected%5Bi%5D%2C%20'%2C%20got%20'%2C%20line)%3B%0A%20%20end%3B%0A%20%20writeln%3B%0A%20%20writeln(passed%2C%20'%20of%202%20checks%20passed')%3B%0A%20%20if%20passed%20%3C%3E%202%20then%0A%20%20%20%20ExitCode%20%3A%3D%201%3B%0Aend.\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>program check_average;\n\n{ Reads the lines average prints and compares them with the expected answer. }\n\nconst\n  expected: array[1..2] of string = ('count: 6', 'mean: 10416.7');\n\nvar\n  line: string;\n  i, passed: integer;\n\nbegin\n  passed := 0;\n  i := 0;\n  while (not eof) and (i &lt; 2) do\n  begin\n    readln(line);\n    i := i + 1;\n    if line = expected[i] then\n    begin\n      passed := passed + 1;\n      writeln('PASS  line ', i, ': ', line);\n    end\n    else\n      writeln('FAIL  line ', i, ': expected ', expected[i], ', got ', line);\n  end;\n  writeln;\n  writeln(passed, ' of 2 checks passed');\n  if passed &lt;&gt; 2 then\n    ExitCode := 1;\nend.\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>With the buggy source still in place, compile both files and pipe the program&#39;s output into the checker.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20fpc%20-vw%20average.pas%20%26%26%20fpc%20-vw%20check_average.pas%20%26%26%20.%2Faverage%2012000%2015000%209500%2010500%208000%207500%20%7C%20.%2Fcheck_average%0APASS%20%20line%201%3A%20count%3A%206%0AFAIL%20%20line%202%3A%20expected%20mean%3A%2010416.7%2C%20got%20mean%3A%20-506%0A%0A1%20of%202%20checks%20passed\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ fpc -vw average.pas &amp;&amp; fpc -vw check_average.pas &amp;&amp; .\u002Faverage 12000 15000 9500 10500 8000 7500 | .\u002Fcheck_average\u003C\u002Fspan>\nPASS  line 1: count: 6\nFAIL  line 2: expected mean: 10416.7, got mean: -506\n\n1 of 2 checks passed\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>That is the red run. Line 2 fails, and \u003Ccode>check_average\u003C\u002Fcode> exits with status 1. Now replace \u003Ccode>average.pas\u003C\u002Fcode> with the fixed source.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PASCAL\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"program%20average%3B%0A%0A%7B%20Sums%20the%20prices%20given%20on%20the%20command%20line%20and%20prints%20the%20count%20and%20the%20mean.%20%7D%0A%0Auses%20SysUtils%3B%0A%0Avar%0A%20%20i%2C%20count%3A%20integer%3B%0A%20%20sum%3A%20longint%3B%0A%0Abegin%0A%20%20sum%20%3A%3D%200%3B%0A%20%20count%20%3A%3D%20ParamCount%3B%0A%20%20for%20i%20%3A%3D%201%20to%20count%20do%0A%20%20%20%20sum%20%3A%3D%20sum%20%2B%20StrToInt(ParamStr(i))%3B%0A%20%20writeln('count%3A%20'%2C%20count)%3B%0A%20%20if%20count%20%3D%200%20then%0A%20%20%20%20writeln('mean%3A%20no%20data')%0A%20%20else%0A%20%20%20%20writeln('mean%3A%20'%2C%20sum%20%2F%20count%3A0%3A1)%3B%0Aend.\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>program average;\n\n{ Sums the prices given on the command line and prints the count and the mean. }\n\nuses SysUtils;\n\nvar\n  i, count: integer;\n  sum: longint;\n\nbegin\n  sum := 0;\n  count := ParamCount;\n  for i := 1 to count do\n    sum := sum + StrToInt(ParamStr(i));\n  writeln('count: ', count);\n  if count = 0 then\n    writeln('mean: no data')\n  else\n    writeln('mean: ', sum \u002F count:0:1);\nend.\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Run the same command again.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20fpc%20-vw%20average.pas%20%26%26%20.%2Faverage%2012000%2015000%209500%2010500%208000%207500%20%7C%20.%2Fcheck_average%0APASS%20%20line%201%3A%20count%3A%206%0APASS%20%20line%202%3A%20mean%3A%2010416.7%0A%0A2%20of%202%20checks%20passed\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ fpc -vw average.pas &amp;&amp; .\u002Faverage 12000 15000 9500 10500 8000 7500 | .\u002Fcheck_average\u003C\u002Fspan>\nPASS  line 1: count: 6\nPASS  line 2: mean: 10416.7\n\n2 of 2 checks passed\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>That is the green run, with exit status 0. The run with no prices, the one that started all this, no longer crashes.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20fpc%20-vw%20average.pas%20%26%26%20.%2Faverage%0Acount%3A%200%0Amean%3A%20no%20data\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ fpc -vw average.pas &amp;&amp; .\u002Faverage\u003C\u002Fspan>\ncount: 0\nmean: no data\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Rebuild with \u003Ccode>-gl\u003C\u002Fcode> first when a program stops at a bare hex address, and set a breakpoint one line before the calculation when it exits 0 with the wrong number.\u003C\u002Fp>\n","\u003Cul>\n\u003Cli>An unhandled exception prints a hex address; \u003Ccode>-gl\u003C\u002Fcode> makes FPC add \u003Ccode>main, line 17 of average.pas\u003C\u002Fcode> to it.\u003C\u002Fli>\n\u003Cli>gdb stops the program where it breaks and prints the variables, which a line number alone cannot tell you.\u003C\u002Fli>\n\u003Cli>In FPC&#39;s default mode \u003Ccode>integer\u003C\u002Fcode> is 2 bytes, so six prices that add to 62500 leave the variable at -3036.\u003C\u002Fli>\n\u003Cli>\u003Ccode>sum: longint\u003C\u002Fcode> and \u003Ccode>\u002F\u003C\u002Fcode> with \u003Ccode>:0:1\u003C\u002Fcode> fix both the wrapped sum and the truncated mean.\u003C\u002Fli>\n\u003Cli>\u003Ccode>-Cr\u003C\u002Fcode> turns the silent wrap into a range check error that names the line; \u003Ccode>-Co\u003C\u002Fcode> alone did not catch it on this build.\u003C\u002Fli>\n\u003Cli>A checker that reads the program&#39;s output turns a wrong number nobody noticed into a failing line.\u003C\u002Fli>\n\u003C\u002Ful>\n",[170,188,210,215,232,252],{"id":171,"title":172,"title_id":173,"slug":174,"excerpt":175,"excerpt_id":176,"has_translation":12,"published_at":177,"reading_time":178,"hidden_from_listing":15,"tags":179,"thumbnail_image":21,"og_image":183,"series":184,"authors":185},164,"Python Capstone: Why a Blank CSV Field Cut the Class Average","Python Capstone: Kenapa Satu Kolom CSV Kosong Memotong Rata-rata Kelas","python-capstone-gradebook","A gradebook reads four students and writes a JSON report. The class average says 52.42, because two empty fields became zeros.","Buku nilai membaca empat siswa dan menulis laporan JSON. Rata-rata kelasnya bilang 52.42, karena dua kolom kosong berubah jadi nol.","2026-11-21T01:00:00.000Z",8,[180,181,182],"python","input-output","cli","\u002Fog\u002Fpython-capstone-gradebook.png",{"id":149,"title":55,"title_id":56,"slug":57},[186],{"authors_id":187},{"id":99,"name":100,"slug":101,"role":102,"profile_picture":21},{"id":189,"title":190,"title_id":191,"slug":192,"excerpt":193,"excerpt_id":194,"has_translation":12,"published_at":177,"reading_time":195,"hidden_from_listing":15,"tags":196,"thumbnail_image":21,"og_image":201,"series":202,"authors":207},48,"What a Linked List Actually Is","Tentang Struktur Data LinkedList","tentang-struktur-data-linked-list","A linked list is a linear chain of nodes, each holding data and a pointer to the next node. Here is what that chain looks like, what it costs next to an array, and the same minimal implementation in Java, Python, and JavaScript.","Linked list adalah rantai linear berisi node, dan setiap node menyimpan data plus pointer ke node berikutnya. Ini bentuk rantainya, ongkosnya dibanding array, dan implementasi paling sederhana dalam Java, Python, serta JavaScript.",4,[197,198,199,200],"struktur-data","linked-list","pointer","konsep","\u002Fog\u002Ftentang-struktur-data-linked-list.png",{"id":203,"title":204,"title_id":205,"slug":206},28,"Linear Data Structures","Struktur Data Linear","asd-struktur-linear",[208],{"authors_id":209},{"id":99,"name":100,"slug":101,"role":102,"profile_picture":21},{"id":104,"title":105,"title_id":106,"slug":107,"excerpt":108,"excerpt_id":109,"has_translation":12,"published_at":110,"reading_time":111,"hidden_from_listing":15,"tags":112,"thumbnail_image":21,"og_image":116,"series":211,"authors":212},{"id":90,"title":67,"title_id":68,"slug":69},[213],{"authors_id":214},{"id":99,"name":100,"slug":101,"role":102,"profile_picture":21},{"id":216,"title":217,"title_id":218,"slug":219,"excerpt":220,"excerpt_id":221,"has_translation":12,"published_at":110,"reading_time":111,"hidden_from_listing":15,"tags":222,"thumbnail_image":21,"og_image":223,"series":224,"authors":229},162,"Python File I\u002FO: Why the Second Read Came Back Empty","Python File I\u002FO: Kenapa Pembacaan Kedua Kembali Kosong","python-file-read-write","A notes script saves a line, prints it back, then counts zero. The file on disk is correct: `read()` left the pointer at the end, so the second call returned an empty string. Read once into a variable, or `seek(0)`, and the count matches the file.","Skrip catatan menyimpan satu baris, mencetaknya kembali, lalu menghitung nol. Berkas di disk sudah benar: `read()` meninggalkan pointer di ujung, jadi panggilan kedua mengembalikan string kosong. Baca sekali ke sebuah variabel, atau `seek(0)`, dan hitungannya cocok dengan berkas.",[180,181],"\u002Fog\u002Fpython-file-read-write.png",{"id":225,"title":226,"title_id":227,"slug":228},18,"Working with Python Scripts","Menggunakan Script Python","python-pemrograman-dengan-script",[230],{"authors_id":231},{"id":99,"name":100,"slug":101,"role":102,"profile_picture":21},{"id":233,"title":234,"title_id":235,"slug":236,"excerpt":237,"excerpt_id":238,"has_translation":12,"published_at":239,"reading_time":84,"hidden_from_listing":15,"tags":240,"thumbnail_image":21,"og_image":243,"series":244,"authors":249},47,"Why Understanding Algorithms and Data Structures Actually Matters","Pentingnya Memahami Algoritma dan Struktur Data","pentingnya-memahami-algoritma-dan-struktur-data","An algorithm is an ordered list of steps, and that order decides how expensive a problem is. The examples are on the back of an instant noodle packet, in a factorial, and behind ctrl+z.","Sebagai konsep fundamental, algoritma menentukan seberapa mahal sebuah masalah diselesaikan. Contohnya ada di bungkus mie instan, di bilangan faktorial, dan di tombol undo.","2026-11-19T01:00:00.000Z",[241,197,200,242],"algoritma","dasar","\u002Fog\u002Fpentingnya-memahami-algoritma-dan-struktur-data.png",{"id":245,"title":246,"title_id":247,"slug":248},27,"About Algorithms and Data Structures","Tentang Algoritma dan Struktur Data","asd-intro",[250],{"authors_id":251},{"id":99,"name":100,"slug":101,"role":102,"profile_picture":21},{"id":77,"title":78,"title_id":79,"slug":80,"excerpt":81,"excerpt_id":82,"has_translation":12,"published_at":83,"reading_time":84,"hidden_from_listing":15,"tags":85,"thumbnail_image":21,"og_image":88,"series":253,"authors":254},{"id":90,"title":67,"title_id":68,"slug":69},[255],{"authors_id":256},{"id":99,"name":100,"slug":101,"role":102,"profile_picture":21},[258,262,265,268,271,274],{"text":259,"depth":260,"id":261},"The address is not a line number",2,"the-address-is-not-a-line-number",{"text":263,"depth":260,"id":264},"Let gdb stop it where it breaks","let-gdb-stop-it-where-it-breaks",{"text":266,"depth":260,"id":267},"Stop it one line earlier and look inside","stop-it-one-line-earlier-and-look-inside",{"text":269,"depth":260,"id":270},"The sum that went negative","the-sum-that-went-negative",{"text":272,"depth":260,"id":273},"Make the silent version stop too","make-the-silent-version-stop-too",{"text":275,"depth":260,"id":276},"A check you can run","a-check-you-can-run",1795825297412]